#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, unsigned int,
                           char *);
int /*<<< orphan*/ get_stdin(char **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int main(int argc, char *argv[]) {
  char *name = NULL;
  unsigned int age = 0;
  char *username = NULL;
  char *logfile = "logfile";
  FILE *log = NULL;
  printf("What is your name? ");
  get_stdin(&name);
  printf("What is your age? ");
  scanf("%i", &age);
  printf("What is your username? ");
  get_stdin(&username);
  printf("your name is %s, you are %i years old, and your username is %s\n",
         name, age, username);
  log = fopen(logfile, "a");
  fprintf(log,
          "your name is %s, you are %i years old, and your username is %s\n",
          name, age, username);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe7c(%rip),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1050 <get_stdin@plt>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe73(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x28(%rbp),%rdi
call   1050 <get_stdin@plt>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
lea    0xe2b(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movq   $0x0,0x18(%rsp)
movl   $0x0,0xc(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x18(%rsp),%rdi
call   1050 <get_stdin@plt>
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rdi
call   1050 <get_stdin@plt>
mov    0x18(%rsp),%rsi
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%rcx
lea    0xe77(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe1c(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1070 <fopen@plt>
mov    0x18(%rsp),%rdx
mov    0xc(%rsp),%ecx
mov    0x10(%rsp),%r8
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"logfile\00"
@.str.1 = [20 x i8] c"What is your name? \00"
@.str.2 = [19 x i8] c"What is your age? \00"
@.str.3 = [3 x i8] c"%i\00"
@.str.4 = [24 x i8] c"What is your username? \00"
@.str.5 = [64 x i8] c"your name is %s, you are %i years old, and your username is %s\0A\00"
@.str.6 = [2 x i8] c"a\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i32 0, i32* %7
store i8* null, i8** %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %9
store i32* null, i32** %10
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @get_stdin(i8** %6)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @get_stdin(i8** %8)
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = load i8*, i8** %8
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* %17, i32 %18, i8* %19)
%21 = load i8*, i8** %9
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %22, i32** %10
%23 = load i32*, i32** %10
%24 = load i8*, i8** %6
%25 = load i32, i32* %7
%26 = load i8*, i8** %8
%27 = call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* %24, i32 %25, i8* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"logfile\00"
@.str.1 = [20 x i8] c"What is your name? \00"
@.str.2 = [19 x i8] c"What is your age? \00"
@.str.3 = [3 x i8] c"%i\00"
@.str.4 = [24 x i8] c"What is your username? \00"
@.str.5 = [64 x i8] c"your name is %s, you are %i years old, and your username is %s\0A\00"
@.str.6 = [2 x i8] c"a\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @get_stdin(i8** %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @get_stdin(i8** %5)
%15 = load i8*, i8** %3
%16 = load i32, i32* %4
%17 = load i8*, i8** %5
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* %15, i32 %16, i8* %17)
%19 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = load i8*, i8** %5
%23 = call i32 @fprintf(i32* %19, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* %20, i32 %21, i8* %22)
ret i32 0
}