#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *malloc(size_t);
int /*<<< orphan*/ putchar(int /*<<< orphan*/);
char *strcat(char *, char *);
int main(void) {
  char *s;
  s = malloc((size_t)50);
  s = strcat(s, "God be with you, goodwife Wallace!\n");
  while (*s != '\0')
    putchar(*(s++));
  free(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x32,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1060 <strcat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119d <main+0x5d>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1040 <putchar@plt>
jmp    1171 <main+0x31>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x32,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <strlen@plt>
movups 0xeb0(%rip),%xmm0
movups %xmm0,0x10(%r14,%rax,1)
movups 0xe93(%rip),%xmm0
movups %xmm0,(%r14,%rax,1)
movl   $0xa2165,0x20(%r14,%rax,1)
mov    (%r14),%al
test   %al,%al
je     11aa <main+0x6a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
lea    0x1(%r14),%rbx
call   1040 <putchar@plt>
movzbl 0x1(%r14),%eax
mov    %rbx,%r14
test   %al,%al
jne    1190 <main+0x50>
jmp    11ad <main+0x6d>
mov    %r14,%rbx
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [36 x i8] c"God be with you, goodwife Wallace!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i8* @malloc(i64 50)
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strcat(i8* %4, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %2
br label %6
6: ; preds = %11, %0
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %2
%14 = load i8, i8* %12
%15 = sext i8 %14 to i32
%16 = call i32 @putchar(i32 %15)
br label %6
17: ; preds = %6
%18 = load i8*, i8** %2
%19 = call i32 @free(i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"God be with you, goodwife Wallace!\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(50) i8* @malloc(i64 50)
%2 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%3 = getelementptr i8, i8* %1, i64 %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(36) %3, i8* align 1 dereferenceable(36) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 36, i1 false)
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %0, %6
%7 = phi i8 [ %12, %6 ], [ %4, %0 ]
%8 = phi i8* [ %10, %6 ], [ %1, %0 ]
%9 = sext i8 %7 to i32
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = tail call i32 @putchar(i32 %9)
%12 = load i8, i8* %10
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %6, %0
%15 = phi i8* [ %1, %0 ], [ %10, %6 ]
%16 = tail call i32 @free(i8* %15)
ret i32 0
}