#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*/ exit(int);
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ remove_newline(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strncpy(char *, char *, size_t);
int main(int argc, char *argv[]) {
  size_t bytes_read = 0;
  size_t number_of_bytes = 5;
  char firststring[number_of_bytes + 1];
  char secondstring[number_of_bytes + 1];
  char *tempstring = NULL;
  printf("Type something already:\n");
  getline(&tempstring, &bytes_read, stdin);
  if (bytes_read == -1) {
    printf("ERROR\n");
    exit(1);
  }
  remove_newline(tempstring);
  strncpy(firststring, tempstring, number_of_bytes);
  printf("Type something again:\n");
  getline(&tempstring, &bytes_read, stdin);
  if (bytes_read == -1) {
    printf("ERROR\n");
    exit(1);
  }
  remove_newline(tempstring);
  strncpy(secondstring, tempstring, number_of_bytes);
  printf("\n");
  printf("firststring: %s\n", firststring);
  printf("secondstring: %s\n", secondstring);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x5,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
mov    %rdx,%rax
add    $0x1,%rax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
add    $0x10,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdx
mov    %rdx,%rax
add    $0x1,%rax
add    $0x10,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%edx
lea    -0x40(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <getline@plt>
cmpq   $0xffffffffffffffff,-0x18(%rbp)
jne    1214 <main+0xc4>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x40(%rbp),%rdi
call   1040 <remove_newline@plt>
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <strncpy@plt>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edx
lea    -0x40(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <getline@plt>
cmpq   $0xffffffffffffffff,-0x18(%rbp)
jne    1275 <main+0x125>
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x40(%rbp),%rdi
call   1040 <remove_newline@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <strncpy@plt>
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%rsi
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%rsi
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsp,%r14
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xe91(%rip),%rdi
call   1050 <puts@plt>
mov    0x2e4a(%rip),%rbx
mov    (%rbx),%edx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1080 <getline@plt>
cmpq   $0xffffffffffffffff,0x8(%rsp)
je     1252 <main+0xe2>
mov    (%rsp),%rdi
call   1060 <remove_newline@plt>
mov    (%rsp),%rsi
lea    0x10(%rsp),%rdi
mov    $0x5,%edx
call   1040 <strncpy@plt>
lea    0xe5f(%rip),%rdi
call   1050 <puts@plt>
mov    (%rbx),%edx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1080 <getline@plt>
cmpq   $0xffffffffffffffff,0x8(%rsp)
je     1252 <main+0xe2>
mov    (%rsp),%rdi
call   1060 <remove_newline@plt>
mov    (%rsp),%rsi
lea    0x20(%rsp),%rbx
mov    $0x5,%edx
mov    %rbx,%rdi
call   1040 <strncpy@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdd8(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdd6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rsp
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdf8(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Type something already:\0A\00"
@stdin = global i32 0
@.str.1 = [7 x i8] c"ERROR\0A\00"
@.str.2 = [23 x i8] c"Type something again:\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [17 x i8] c"firststring: %s\0A\00"
@.str.5 = [18 x i8] c"secondstring: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
store i64 5, i64* %7
%12 = load i64, i64* %7
%13 = add i64 %12, 1
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %8
%15 = alloca i8, i64 %13
store i64 %13, i64* %9
%16 = load i64, i64* %7
%17 = add i64 %16, 1
%18 = alloca i8, i64 %17
store i64 %17, i64* %10
store i8* null, i8** %11
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @stdin
%21 = call i32 @getline(i8** %11, i64* %6, i32 %20)
%22 = load i64, i64* %6
%23 = icmp eq i64 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %2
%28 = load i8*, i8** %11
%29 = call i32 @remove_newline(i8* %28)
%30 = load i8*, i8** %11
%31 = load i64, i64* %7
%32 = call i32 @strncpy(i8* %15, i8* %30, i64 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%34 = load i32, i32* @stdin
%35 = call i32 @getline(i8** %11, i64* %6, i32 %34)
%36 = load i64, i64* %6
%37 = icmp eq i64 %36, -1
br i1 %37, label %38, label %41
38: ; preds = %27
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %27
%42 = load i8*, i8** %11
%43 = call i32 @remove_newline(i8* %42)
%44 = load i8*, i8** %11
%45 = load i64, i64* %7
%46 = call i32 @strncpy(i8* %18, i8* %44, i64 %45)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %18)
store i32 0, i32* %3
%50 = load i8*, i8** %8
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.4 = [17 x i8] c"firststring: %s\0A\00"
@.str.5 = [18 x i8] c"secondstring: %s\0A\00"
@str = [24 x i8] c"Type something already:\00"
@str.6 = [22 x i8] c"Type something again:\00"
@str.8 = [6 x i8] c"ERROR\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%6 = tail call i8* @llvm.stacksave()
%7 = alloca [6 x i8]
%8 = alloca [6 x i8]
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%11 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* @stdin
%14 = call i32 @getline(i8** %4, i64* %3, i32 %13)
%15 = load i64, i64* %3
%16 = icmp eq i64 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8*, i8** %4
%22 = call i32 @remove_newline(i8* %21)
%23 = load i8*, i8** %4
%24 = call i32 @strncpy(i8* %10, i8* %23, i64 5)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
%26 = load i32, i32* @stdin
%27 = call i32 @getline(i8** %4, i64* %3, i32 %26)
%28 = load i64, i64* %3
%29 = icmp eq i64 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %20
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %20
%34 = load i8*, i8** %4
%35 = call i32 @remove_newline(i8* %34)
%36 = load i8*, i8** %4
%37 = call i32 @strncpy(i8* %9, i8* %36, i64 5)
%38 = call i32 @putchar(i32 10)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %9)
ret i32 0
}