#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*/ gets(char *);
int /*<<< orphan*/ prints(char *);
main() {
  char name[64];
  while (1) {
    prints("What's your name? ");
    gets(name);
    if (name[0] == 0)
      break;
    prints("Welcome ");
    prints(name);
    prints("\n\r");
  }
  prints("return to assembly and hang\n\r");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <prints@plt>
lea    -0x50(%rbp),%rdi
call   1040 <gets@plt>
movsbl -0x50(%rbp),%eax
cmp    $0x0,%eax
jne    1156 <main+0x36>
jmp    117c <main+0x5c>
lea    0xeb6(%rip),%rdi
call   1030 <prints@plt>
lea    -0x50(%rbp),%rdi
call   1030 <prints@plt>
lea    0xec5(%rip),%rdi
call   1030 <prints@plt>
jmp    112f <main+0xf>
lea    0xe99(%rip),%rdi
call   1030 <prints@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xece(%rip),%rdi
call   1030 <prints@plt>
mov    %rsp,%rdi
call   1040 <gets@plt>
cmpb   $0x0,(%rsp)
je     118e <main+0x6e>
lea    0xec7(%rip),%r14
mov    %rsp,%rbx
lea    0xee1(%rip),%r15
lea    0xea3(%rip),%r12
nopl   (%rax)
mov    %r14,%rdi
call   1030 <prints@plt>
mov    %rbx,%rdi
call   1030 <prints@plt>
mov    %r15,%rdi
call   1030 <prints@plt>
mov    %r12,%rdi
call   1030 <prints@plt>
mov    %rbx,%rdi
call   1040 <gets@plt>
cmpb   $0x0,(%rsp)
jne    1160 <main+0x40>
lea    0xe87(%rip),%rdi
call   1030 <prints@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"What's your name? \00"
@.str.1 = [9 x i8] c"Welcome \00"
@.str.2 = [3 x i8] c"\0A\0D\00"
@.str.3 = [30 x i8] c"return to assembly and hang\0A\0D\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %0, %12
%4 = call i32 @prints(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%6 = call i32 @gets(i8* %5)
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %3
br label %17
12: ; preds = %3
%13 = call i32 @prints(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%15 = call i32 @prints(i8* %14)
%16 = call i32 @prints(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %3
17: ; preds = %11
%18 = call i32 @prints(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [19 x i8] c"What's your name? \00"
@.str.1 = [9 x i8] c"Welcome \00"
@.str.2 = [3 x i8] c"\0A\0D\00"
@.str.3 = [30 x i8] c"return to assembly and hang\0A\0D\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = call i32 @prints(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %0, %7
%8 = call i32 @prints(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @prints(i8* %2)
%10 = call i32 @prints(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @prints(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @gets(i8* %2)
%13 = load i8, i8* %2
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %7
15: ; preds = %7, %0
%16 = call i32 @prints(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}