#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char buffer[64];
  int x;
  printf("Your name: ");
  fgets(buffer, 64, stdin);
  for (x = 0; x < 64; x++) {
    if (buffer[x] == '\n') {
      buffer[x] = '\0';
      break;
    }
  }
  printf("Hello, %s\n", buffer);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    0x2ea0(%rip),%rax
mov    (%rax),%edx
mov    $0x40,%esi
call   1040 <fgets@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x40,-0x54(%rbp)
jge    1198 <main+0x78>
movslq -0x54(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    1185 <main+0x65>
movslq -0x54(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
jmp    1198 <main+0x78>
jmp    118a <main+0x6a>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    115b <main+0x3b>
lea    -0x50(%rbp),%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2eac(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x40,%esi
call   1040 <fgets@plt>
nopl   0x0(%rax,%rax,1)
cmpb   $0xa,(%rsp,%rbx,1)
je     1187 <main+0x67>
cmpb   $0xa,0x1(%rsp,%rbx,1)
je     1177 <main+0x57>
cmpb   $0xa,0x2(%rsp,%rbx,1)
je     117d <main+0x5d>
cmpb   $0xa,0x3(%rsp,%rbx,1)
je     1183 <main+0x63>
add    $0x4,%rbx
cmp    $0x40,%rbx
jne    1150 <main+0x30>
jmp    118d <main+0x6d>
add    $0x1,%rbx
jmp    1187 <main+0x67>
add    $0x2,%rbx
jmp    1187 <main+0x67>
add    $0x3,%rbx
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xe78(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Your name: \00"
@stdin = global i32 0
@.str.1 = [11 x i8] c"Hello, %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 64, i32 %6)
store i32 0, i32* %3
br label %8
8: ; preds = %23, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 64
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %20
store i8 0, i8* %21
br label %26
22: ; preds = %11
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %8
26: ; preds = %18, %8
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Your name: \00"
@stdin = global i32 0
@.str.1 = [11 x i8] c"Hello, %s\0A\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 64, i32 %4)
br label %6
6: ; preds = %30, %0
%7 = phi i64 [ 0, %0 ], [ %31, %30 ]
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %15
11: ; preds = %25, %20, %15, %6
%12 = phi i64 [ %7, %6 ], [ %16, %15 ], [ %21, %20 ], [ %26, %25 ]
%13 = and i64 %12, 4294967295
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %13
store i8 0, i8* %14
br label %33
15: ; preds = %6
%16 = or i64 %7, 1
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 10
br i1 %19, label %11, label %20
20: ; preds = %15
%21 = or i64 %7, 2
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 10
br i1 %24, label %11, label %25
25: ; preds = %20
%26 = or i64 %7, 3
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 10
br i1 %29, label %11, label %30
30: ; preds = %25
%31 = add nuw nsw i64 %7, 4
%32 = icmp eq i64 %31, 64
br i1 %32, label %33, label %6
33: ; preds = %30, %11
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}