#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 */
typedef int /*<<< orphan*/ newInput;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  char greeting[] = {'H', 'e', 'l', 'l', 'o', '\0'};
  char greet2[] = "Hello again";
  printf("Greeting: %s\n", greeting);
  printf("Greeting2: %s\n", greet2);
  char inputStr[100];
  printf("Input some text: ");
  scanf("%s", inputStr);
  printf("You entered: %s\n", inputStr);
  char newInput[50];
  printf("Enter some more text with spaces: ");
  fgets(newInput, sizeof(newInput), stdin);
  printf("You entered: %s\n", newInput);
  char *line = NULL;
  size_t len = 0;
  printf("enter some more text: ");
  getline(&line, &len, stdin);
  printf("You entered: %s\n", line);
  if (argc > 1) {
    printf("argc is %i\n", argc);
    for (int c = 1; c < argc; ++c) {
      printf("'%s' was passed in from the cli using argv[%i]\n", argv[c], c);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xea1(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xe9b(%rip),%ax
mov    %ax,-0x12(%rbp)
mov    0xe92(%rip),%rax
mov    %rax,-0x22(%rbp)
mov    0xe90(%rip),%eax
mov    %eax,-0x1a(%rbp)
lea    -0x16(%rbp),%rsi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x22(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x90(%rbp),%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xd0(%rbp),%rdi
mov    0x2df1(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1040 <fgets@plt>
lea    -0xd0(%rbp),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0xd8(%rbp)
movq   $0x0,-0xe0(%rbp)
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edx
lea    -0xd8(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1060 <getline@plt>
mov    -0xd8(%rbp),%rsi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    12dd <main+0x19d>
mov    -0x8(%rbp),%esi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12d8 <main+0x198>
mov    -0x10(%rbp),%rax
movslq -0xe4(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0xe4(%rbp),%edx
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1292 <main+0x152>
jmp    12dd <main+0x19d>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe0,%rsp
mov    %rsi,%r15
mov    %edi,%r14d
movw   $0x6f,0xc(%rsp)
movl   $0x6c6c6548,0x8(%rsp)
6c
movabs $0x6761206f6c6c6548,%rax
20 61 67
mov    %rax,0x20(%rsp)
movl   $0x6e6961,0x28(%rsp)
lea    0xe90(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    0x70(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xe7a(%rip),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2dfc(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1040 <fgets@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movq   $0x0,0x10(%rsp)
movq   $0x0,0x18(%rsp)
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x0(%rbp),%edx
lea    0x10(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1060 <getline@plt>
mov    0x10(%rsp),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x2,%r14d
jl     1299 <main+0x159>
lea    0xe33(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14d,%ebx
mov    $0x1,%ebp
lea    0xe26(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbp,8),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1280 <main+0x140>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.greeting = [6 x i8] c"Hello\00"
@__const.main.greet2 = [12 x i8] c"Hello again\00"
@.str = [14 x i8] c"Greeting: %s\0A\00"
@.str.1 = [15 x i8] c"Greeting2: %s\0A\00"
@.str.2 = [18 x i8] c"Input some text: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [17 x i8] c"You entered: %s\0A\00"
@.str.5 = [35 x i8] c"Enter some more text with spaces: \00"
@stdin = global i32 0
@.str.6 = [23 x i8] c"enter some more text: \00"
@.str.7 = [12 x i8] c"argc is %i\0A\00"
@.str.8 = [48 x i8] c"'%s' was passed in from the cli using argv[%i]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x i8]
%7 = alloca [12 x i8]
%8 = alloca [100 x i8]
%9 = alloca [50 x i8]
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = bitcast [6 x i8]* %6 to i8*
%14 = bitcast [12 x i8]* %7 to i8*
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%26 = load i32, i32* @stdin
%27 = call i32 @fgets(i8* %25, i32 50, i32 %26)
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %28)
store i8* null, i8** %10
store i64 0, i64* %11
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%31 = load i32, i32* @stdin
%32 = call i32 @getline(i8** %10, i64* %11, i32 %31)
%33 = load i8*, i8** %10
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %33)
%35 = load i32, i32* %4
%36 = icmp sgt i32 %35, 1
br i1 %36, label %37, label %56
37: ; preds = %2
%38 = load i32, i32* %4
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %38)
store i32 1, i32* %12
br label %40
40: ; preds = %52, %37
%41 = load i32, i32* %12
%42 = load i32, i32* %4
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %55
44: ; preds = %40
%45 = load i8**, i8*** %5
%46 = load i32, i32* %12
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = load i32, i32* %12
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i8* %49, i32 %50)
br label %52
52: ; preds = %44
%53 = load i32, i32* %12
%54 = add nsw i32 %53, 1
store i32 %54, i32* %12
br label %40
55: ; preds = %40
br label %56
56: ; preds = %55, %2
ret i32 0
}

LLVM IR (-O2):
@__const.main.greeting = [6 x i8] c"Hello\00"
@__const.main.greet2 = [12 x i8] c"Hello again\00"
@.str = [14 x i8] c"Greeting: %s\0A\00"
@.str.1 = [15 x i8] c"Greeting2: %s\0A\00"
@.str.2 = [18 x i8] c"Input some text: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [17 x i8] c"You entered: %s\0A\00"
@.str.5 = [35 x i8] c"Enter some more text with spaces: \00"
@stdin = global i32 0
@.str.6 = [23 x i8] c"enter some more text: \00"
@.str.7 = [12 x i8] c"argc is %i\0A\00"
@.str.8 = [48 x i8] c"'%s' was passed in from the cli using argv[%i]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [6 x i8]
%4 = alloca [12 x i8]
%5 = alloca [100 x i8]
%6 = alloca [50 x i8]
%7 = alloca i8*
%8 = alloca i64
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %9)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%19 = load i32, i32* @stdin
%20 = call i32 @fgets(i8* %17, i32 50, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %17)
%22 = bitcast i8** %7 to i8*
store i8* null, i8** %7
%23 = bitcast i64* %8 to i8*
store i64 0, i64* %8
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%25 = load i32, i32* @stdin
%26 = call i32 @getline(i8** %7, i64* %8, i32 %25)
%27 = load i8*, i8** %7
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = icmp sgt i32 %0, 1
br i1 %29, label %30, label %41
30: ; preds = %2
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i32 %0)
%32 = zext i32 %0 to i64
br label %33
33: ; preds = %30, %33
%34 = phi i64 [ 1, %30 ], [ %39, %33 ]
%35 = getelementptr inbounds i8*, i8** %1, i64 %34
%36 = load i8*, i8** %35
%37 = trunc i64 %34 to i32
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i8* %36, i32 %37)
%39 = add nuw nsw i64 %34, 1
%40 = icmp eq i64 %39, %32
br i1 %40, label %41, label %33
41: ; preds = %33, %2
ret i32 0
}