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

/* Variables and functions */
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, const char *argv[]) {
  char str1[20] = "1234567890";
  char str2[20];
  char str3[5];
  strcpy(str2, str1);
  puts(str2);
  strncpy(str3, str1, sizeof(str3) - 1);
  puts(str3);
  int c = 'f';
  int ch2;
  fputc(c, stdout);
  while ((ch2 = getchar()) != -1) {
    putchar(ch2);
  }
  char buffer[5];
  gets(buffer);
  puts(buffer);
  int buflen = strlen(buffer);
  printf("strlen(buffer) : %d \n", buflen);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe53(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe50(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe4e(%rip),%eax
mov    %eax,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <strcpy@plt>
lea    -0x50(%rbp),%rdi
call   1060 <puts@plt>
lea    -0x55(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x4,%edx
call   1040 <strncpy@plt>
lea    -0x55(%rbp),%rdi
call   1060 <puts@plt>
movl   $0x66,-0x5c(%rbp)
mov    -0x5c(%rbp),%edi
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
call   1090 <fputc@plt>
mov    $0x0,%al
call   10a0 <getchar@plt>
mov    %eax,-0x60(%rbp)
cmp    $0xffffffff,%eax
je     122e <main+0x9e>
mov    -0x60(%rbp),%edi
call   1030 <putchar@plt>
jmp    120e <main+0x7e>
lea    -0x65(%rbp),%rdi
call   10b0 <gets@plt>
lea    -0x65(%rbp),%rdi
call   1060 <puts@plt>
lea    -0x65(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%esi
lea    0xdbe(%rip),%rdi
call   1080 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movaps 0xe62(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
lea    0x30(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <puts@plt>
lea    0xb(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
call   1060 <puts@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%esi
mov    $0x66,%edi
call   1090 <fputc@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <getchar@plt>
cmp    $0xffffffff,%eax
je     1215 <main+0x85>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    1200 <main+0x70>
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
call   10b0 <gets@plt>
mov    %rbx,%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
lea    0xddb(%rip),%rdi
mov    %eax,%esi
call   1080 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str1 = [20 x i8] c"1234567890\00\00\00\00\00\00\00\00\00\00"
@stdout = global i32 0
@.str = [22 x i8] c"strlen(buffer) : %d \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x i8]
%7 = alloca [20 x i8]
%8 = alloca [5 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca [5 x i8]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = bitcast [20 x i8]* %6 to i8*
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%18 = call i32 @puts(i8* %17)
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%21 = call i32 @strncpy(i8* %19, i8* %20, i32 4)
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%23 = call i32 @puts(i8* %22)
store i32 102, i32* %9
%24 = load i32, i32* %9
%25 = load i32, i32* @stdout
%26 = call i32 @fputc(i32 %24, i32 %25)
br label %27
27: ; preds = %30, %2
%28 = call i32 (...) @getchar()
store i32 %28, i32* %10
%29 = icmp ne i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %10
%32 = call i32 @putchar(i32 %31)
br label %27
33: ; preds = %27
%34 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 0
%35 = call i32 @gets(i8* %34)
%36 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 0
%37 = call i32 @puts(i8* %36)
%38 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 0
%39 = call i32 @strlen(i8* %38)
store i32 %39, i32* %12
%40 = load i32, i32* %12
%41 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str1 = [20 x i8] c"1234567890\00\00\00\00\00\00\00\00\00\00"
@stdout = global i32 0
@.str = [22 x i8] c"strlen(buffer) : %d \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [20 x i8]
%4 = alloca [20 x i8]
%5 = alloca [5 x i8]
%6 = alloca [5 x i8]
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%10 = call i32 @strcpy(i8* %8, i8* %7)
%11 = call i32 @puts(i8* %8)
%12 = call i32 @strncpy(i8* %9, i8* %7, i32 4)
%13 = call i32 @puts(i8* %9)
%14 = load i32, i32* @stdout
%15 = call i32 @fputc(i32 102, i32 %14)
%16 = call i32 (...) @getchar()
%17 = icmp eq i32 %16, -1
br i1 %17, label %23, label %18
18: ; preds = %2, %18
%19 = phi i32 [ %21, %18 ], [ %16, %2 ]
%20 = call i32 @putchar(i32 %19)
%21 = call i32 (...) @getchar()
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %18
23: ; preds = %18, %2
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%25 = call i32 @gets(i8* %24)
%26 = call i32 @puts(i8* %24)
%27 = call i32 @strlen(i8* %24)
%28 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %27)
ret i32 0
}