#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 */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *, char *);
char *strcat(char *, char *);
int main() {
  int i;
  char a[100];
  for (i = 0; (i < 100) && ((a[i] = getchar()) != EOF); ++i)
    ;
  a[i] = '\0';
  printf("%s\n", strcat(a, "world"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x64,-0x8(%rbp)
mov    %al,-0x71(%rbp)
jge    117c <main+0x4c>
mov    $0x0,%al
call   1040 <getchar@plt>
movslq -0x8(%rbp),%rcx
mov    %al,-0x70(%rbp,%rcx,1)
movsbl %al,%eax
mov    0x2e77(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    118c <main+0x5c>
jmp    119f <main+0x6f>
jmp    1191 <main+0x61>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1149 <main+0x19>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1050 <strcat@plt>
mov    %rax,%rsi
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    0x2eaa(%rip),%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,(%rsp,%rbx,1)
cmp    (%r14),%al
je     115e <main+0x2e>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1140 <main+0x10>
mov    $0x64,%ebx
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
movl   $0x6c726f77,(%rsp,%rax,1)
movw   $0x64,0x4(%rsp,%rax,1)
lea    0xe7c(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@EOF = global i8 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [6 x i8] c"world\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %9
%4 = phi i64 [ 0, %0 ], [ %10, %9 ]
%5 = tail call signext i8 (...) @getchar()
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %4
store i8 %5, i8* %6
%7 = load i8, i8* @EOF
%8 = icmp eq i8 %5, %7
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = add nuw nsw i64 %4, 1
%11 = icmp eq i64 %10, 100
br i1 %11, label %12, label %3
12: ; preds = %9, %3
%13 = phi i64 [ 100, %9 ], [ %4, %3 ]
%14 = and i64 %13, 4294967295
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %14
store i8 0, i8* %15
%16 = call i64 @strlen(i8* %2)
%17 = getelementptr [100 x i8], [100 x i8]* %1, i64 0, i64 %16
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}