1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
|
.file "better_string.c"
.text
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "malloc in init_string"
.LC1:
.string "calloc in init_string"
.text
.p2align 4
.globl init_string
.type init_string, @function
init_string:
.LFB11:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rdi, %rbp
movl $24, %edi
pushq %rbx
.cfi_def_cfa_offset 24
.cfi_offset 3, -24
subq $8, %rsp
.cfi_def_cfa_offset 32
call malloc@PLT
movq %rax, %rbx
testq %rax, %rax
je .L12
.L2:
testq %rbp, %rbp
je .L3
cmpb $0, 0(%rbp)
jne .L4
.L3:
movq $10, 8(%rbx)
movl $1, %esi
movl $10, %edi
call calloc@PLT
movq $0, (%rbx)
movq %rax, 16(%rbx)
addq $8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 24
movq %rbx, %rax
popq %rbx
.cfi_def_cfa_offset 16
popq %rbp
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L4:
.cfi_restore_state
movq %rbp, %rdi
call strlen@PLT
movl $1, %esi
leaq (%rax,%rax), %rdi
movq %rax, (%rbx)
movq %rdi, 8(%rbx)
call calloc@PLT
movq %rax, 16(%rbx)
movq %rax, %rdi
testq %rax, %rax
je .L13
.L6:
movq %rbp, %rsi
call strcpy@PLT
addq $8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 24
movq %rbx, %rax
popq %rbx
.cfi_def_cfa_offset 16
popq %rbp
.cfi_def_cfa_offset 8
ret
.L12:
.cfi_restore_state
leaq .LC0(%rip), %rdi
call die@PLT
jmp .L2
.L13:
leaq .LC1(%rip), %rdi
call die@PLT
movq 16(%rbx), %rdi
jmp .L6
.cfi_endproc
.LFE11:
.size init_string, .-init_string
.p2align 4
.globl string_copy
.type string_copy, @function
string_copy:
.LFB12:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
pushq %rbx
.cfi_def_cfa_offset 24
.cfi_offset 3, -24
subq $8, %rsp
.cfi_def_cfa_offset 32
movq 16(%rdi), %rbp
movl $24, %edi
call malloc@PLT
movq %rax, %rbx
testq %rax, %rax
je .L24
.L15:
testq %rbp, %rbp
je .L16
cmpb $0, 0(%rbp)
jne .L17
.L16:
movq $10, 8(%rbx)
movl $1, %esi
movl $10, %edi
call calloc@PLT
movq $0, (%rbx)
movq %rax, 16(%rbx)
addq $8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 24
movq %rbx, %rax
popq %rbx
.cfi_def_cfa_offset 16
popq %rbp
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L17:
.cfi_restore_state
movq %rbp, %rdi
call strlen@PLT
movq %rbp, %rdi
movq %rax, (%rbx)
call strlen@PLT
movl $1, %esi
leaq (%rax,%rax), %rdi
movq %rdi, 8(%rbx)
call calloc@PLT
movq %rax, 16(%rbx)
movq %rax, %rdi
testq %rax, %rax
je .L25
.L19:
movq %rbp, %rsi
call strcpy@PLT
addq $8, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 24
movq %rbx, %rax
popq %rbx
.cfi_def_cfa_offset 16
popq %rbp
.cfi_def_cfa_offset 8
ret
.L24:
.cfi_restore_state
leaq .LC0(%rip), %rdi
call die@PLT
jmp .L15
.L25:
leaq .LC1(%rip), %rdi
call die@PLT
movq 16(%rbx), %rdi
jmp .L19
.cfi_endproc
.LFE12:
.size string_copy, .-string_copy
.section .rodata.str1.1
.LC2:
.string "realloc on realloc_zero"
.text
.p2align 4
.globl realloc_zero
.type realloc_zero, @function
realloc_zero:
.LFB13:
.cfi_startproc
pushq %r12
.cfi_def_cfa_offset 16
.cfi_offset 12, -16
movq %rsi, %r12
movq %rdx, %rsi
pushq %rbp
.cfi_def_cfa_offset 24
.cfi_offset 6, -24
pushq %rbx
.cfi_def_cfa_offset 32
.cfi_offset 3, -32
movq %rdx, %rbx
call realloc@PLT
movq %rax, %rbp
testq %rax, %rax
je .L30
cmpq %rbx, %r12
jb .L31
.L26:
movq %rbp, %rax
popq %rbx
.cfi_remember_state
.cfi_def_cfa_offset 24
popq %rbp
.cfi_def_cfa_offset 16
popq %r12
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L31:
.cfi_restore_state
subq %r12, %rbx
leaq (%rax,%r12), %rdi
xorl %esi, %esi
movq %rbx, %rdx
call memset@PLT
movq %rbp, %rax
popq %rbx
.cfi_remember_state
.cfi_def_cfa_offset 24
popq %rbp
.cfi_def_cfa_offset 16
popq %r12
.cfi_def_cfa_offset 8
ret
.L30:
.cfi_restore_state
leaq .LC2(%rip), %rdi
call die@PLT
jmp .L26
.cfi_endproc
.LFE13:
.size realloc_zero, .-realloc_zero
.p2align 4
.globl string_concat
.type string_concat, @function
string_concat:
.LFB14:
.cfi_startproc
pushq %r15
.cfi_def_cfa_offset 16
.cfi_offset 15, -16
pushq %r14
.cfi_def_cfa_offset 24
.cfi_offset 14, -24
pushq %r13
.cfi_def_cfa_offset 32
.cfi_offset 13, -32
pushq %r12
.cfi_def_cfa_offset 40
.cfi_offset 12, -40
pushq %rbp
.cfi_def_cfa_offset 48
.cfi_offset 6, -48
pushq %rbx
.cfi_def_cfa_offset 56
.cfi_offset 3, -56
subq $40, %rsp
.cfi_def_cfa_offset 96
movq %fs:40, %rax
movq %rax, 24(%rsp)
xorl %eax, %eax
cmpq $0, (%rsi)
je .L32
movq %rdi, %rbx
movq %rsi, %r15
leaq 22(%rsp), %r13
xorl %ebp, %ebp
jmp .L33
.p2align 4,,10
.p2align 3
.L34:
addq $1, %rax
movq %r13, %rsi
movq %r12, %rdi
addq $1, %rbp
movq %rax, (%rbx)
call strcat@PLT
cmpq (%r15), %rbp
jnb .L32
.L33:
movq 16(%r15), %rax
movq 8(%rbx), %rdi
movb $0, 23(%rsp)
movq 16(%rbx), %r12
movzbl (%rax,%rbp), %eax
leaq -1(%rdi), %rdx
movb %al, 22(%rsp)
movq (%rbx), %rax
cmpq %rdx, %rax
jb .L34
leaq (%rdi,%rdi), %rdx
movslq %edi, %r14
movq %r12, %rdi
movq %rdx, 8(%rbx)
movq %rdx, %rsi
movq %rdx, 8(%rsp)
call realloc@PLT
movq 8(%rsp), %rdx
testq %rax, %rax
movq %rax, %r12
je .L43
cmpq %rdx, %r14
jb .L44
.L36:
movq %r12, 16(%rbx)
movq (%rbx), %rax
jmp .L34
.p2align 4,,10
.p2align 3
.L32:
movq 24(%rsp), %rax
subq %fs:40, %rax
jne .L45
addq $40, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 56
popq %rbx
.cfi_def_cfa_offset 48
popq %rbp
.cfi_def_cfa_offset 40
popq %r12
.cfi_def_cfa_offset 32
popq %r13
.cfi_def_cfa_offset 24
popq %r14
.cfi_def_cfa_offset 16
popq %r15
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L44:
.cfi_restore_state
subq %r14, %rdx
leaq (%rax,%r14), %rdi
xorl %esi, %esi
call memset@PLT
jmp .L36
.L43:
leaq .LC2(%rip), %rdi
call die@PLT
jmp .L36
.L45:
call __stack_chk_fail@PLT
.cfi_endproc
.LFE14:
.size string_concat, .-string_concat
.p2align 4
.globl string_append
.type string_append, @function
string_append:
.LFB15:
.cfi_startproc
pushq %r13
.cfi_def_cfa_offset 16
.cfi_offset 13, -16
pushq %r12
.cfi_def_cfa_offset 24
.cfi_offset 12, -24
pushq %rbp
.cfi_def_cfa_offset 32
.cfi_offset 6, -32
pushq %rbx
.cfi_def_cfa_offset 40
.cfi_offset 3, -40
movq %rdi, %rbx
subq $24, %rsp
.cfi_def_cfa_offset 64
movq 8(%rdi), %rdi
movq 16(%rbx), %rbp
movq %fs:40, %rax
movq %rax, 8(%rsp)
xorl %eax, %eax
movq (%rbx), %rax
movb %sil, 6(%rsp)
leaq -1(%rdi), %rdx
movb $0, 7(%rsp)
cmpq %rdx, %rax
jnb .L52
.L47:
addq $1, %rax
leaq 6(%rsp), %rsi
movq %rbp, %rdi
movq %rax, (%rbx)
call strcat@PLT
movq 8(%rsp), %rax
subq %fs:40, %rax
jne .L53
addq $24, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 40
popq %rbx
.cfi_def_cfa_offset 32
popq %rbp
.cfi_def_cfa_offset 24
popq %r12
.cfi_def_cfa_offset 16
popq %r13
.cfi_def_cfa_offset 8
ret
.p2align 4,,10
.p2align 3
.L52:
.cfi_restore_state
leaq (%rdi,%rdi), %r13
movslq %edi, %r12
movq %rbp, %rdi
movq %r13, 8(%rbx)
movq %r13, %rsi
call realloc@PLT
movq %rax, %rbp
testq %rax, %rax
je .L54
cmpq %r13, %r12
jb .L55
.L49:
movq %rbp, 16(%rbx)
movq (%rbx), %rax
jmp .L47
.p2align 4,,10
.p2align 3
.L55:
movq %r13, %rdx
leaq (%rax,%r12), %rdi
xorl %esi, %esi
subq %r12, %rdx
call memset@PLT
jmp .L49
.L53:
call __stack_chk_fail@PLT
.L54:
leaq .LC2(%rip), %rdi
call die@PLT
jmp .L49
.cfi_endproc
.LFE15:
.size string_append, .-string_append
.p2align 4
.globl string_free
.type string_free, @function
string_free:
.LFB16:
.cfi_startproc
pushq %rbx
.cfi_def_cfa_offset 16
.cfi_offset 3, -16
movq %rdi, %rbx
movq 16(%rdi), %rdi
call free@PLT
movq %rbx, %rdi
popq %rbx
.cfi_def_cfa_offset 8
jmp free@PLT
.cfi_endproc
.LFE16:
.size string_free, .-string_free
.ident "GCC: (GNU) 13.2.1 20230801"
.section .note.GNU-stack,"",@progbits
|