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

/* Variables and functions */
char read_u8();
char *read_str(void) {
  static char str[16];
  int i;
  for (i = 0;; i++) {
    if (!(str[i] = read_u8()))
      break;
    if (i == sizeof(str) - 1) {
      str[i] = 0;
      break;
    }
  }
  return str;
}


x86 assembly (clang, -O0):
<read_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <read_u8@plt>
movslq -0x4(%rbp),%rdx
lea    0x2f0f(%rip),%rcx
mov    %al,(%rcx,%rdx,1)
cmp    $0x0,%al
jne    1141 <read_str+0x31>
jmp    1176 <read_str+0x66>
movslq -0x4(%rbp),%rax
cmp    $0xf,%rax
jne    1163 <read_str+0x53>
movslq -0x4(%rbp),%rcx
lea    0x2ee6(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
jmp    1176 <read_str+0x66>
jmp    1168 <read_str+0x58>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    111f <read_str+0xf>
lea    0x2ec3(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_str>:
push   %rax
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2f22(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2f0e(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2efa(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2ee6(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2ed2(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2ebe(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2eaa(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2e96(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2e82(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2e72(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2e62(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2e52(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2e42(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2e32(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
mov    %al,0x2e22(%rip)
test   %al,%al
je     123e <read_str+0x12e>
xor    %eax,%eax
call   1030 <read_u8@plt>
movb   $0x0,0x2e11(%rip)
lea    0x2dfb(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@read_str.str = internal global [16 x i8] zeroinitializer
define i8* @read_str() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %18, %0
%3 = call signext i8 (...) @read_u8()
%4 = load i32, i32* %1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds [16 x i8], [16 x i8]* @read_str.str, i64 0, i64 %5
store i8 %3, i8* %6
%7 = icmp ne i8 %3, 0
br i1 %7, label %9, label %8
8: ; preds = %2
br label %21
9: ; preds = %2
%10 = load i32, i32* %1
%11 = sext i32 %10 to i64
%12 = icmp eq i64 %11, 15
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [16 x i8], [16 x i8]* @read_str.str, i64 0, i64 %15
store i8 0, i8* %16
br label %21
17: ; preds = %9
br label %18
18: ; preds = %17
%19 = load i32, i32* %1
%20 = add nsw i32 %19, 1
store i32 %20, i32* %1
br label %2
21: ; preds = %13, %8
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 0)
}

LLVM IR (-O2):
@read_str.str = internal global [16 x i8] zeroinitializer
define i8* @read_str() {
%1 = tail call signext i8 (...) @read_u8()
store i8 %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 0)
%2 = icmp eq i8 %1, 0
br i1 %2, label %47, label %3
3: ; preds = %0
%4 = tail call signext i8 (...) @read_u8()
store i8 %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 1)
%5 = icmp eq i8 %4, 0
br i1 %5, label %47, label %6
6: ; preds = %3
%7 = tail call signext i8 (...) @read_u8()
store i8 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 2)
%8 = icmp eq i8 %7, 0
br i1 %8, label %47, label %9
9: ; preds = %6
%10 = tail call signext i8 (...) @read_u8()
store i8 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 3)
%11 = icmp eq i8 %10, 0
br i1 %11, label %47, label %12
12: ; preds = %9
%13 = tail call signext i8 (...) @read_u8()
store i8 %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 4)
%14 = icmp eq i8 %13, 0
br i1 %14, label %47, label %15
15: ; preds = %12
%16 = tail call signext i8 (...) @read_u8()
store i8 %16, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 5)
%17 = icmp eq i8 %16, 0
br i1 %17, label %47, label %18
18: ; preds = %15
%19 = tail call signext i8 (...) @read_u8()
store i8 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 6)
%20 = icmp eq i8 %19, 0
br i1 %20, label %47, label %21
21: ; preds = %18
%22 = tail call signext i8 (...) @read_u8()
store i8 %22, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 7)
%23 = icmp eq i8 %22, 0
br i1 %23, label %47, label %24
24: ; preds = %21
%25 = tail call signext i8 (...) @read_u8()
store i8 %25, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 8)
%26 = icmp eq i8 %25, 0
br i1 %26, label %47, label %27
27: ; preds = %24
%28 = tail call signext i8 (...) @read_u8()
store i8 %28, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 9)
%29 = icmp eq i8 %28, 0
br i1 %29, label %47, label %30
30: ; preds = %27
%31 = tail call signext i8 (...) @read_u8()
store i8 %31, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 10)
%32 = icmp eq i8 %31, 0
br i1 %32, label %47, label %33
33: ; preds = %30
%34 = tail call signext i8 (...) @read_u8()
store i8 %34, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 11)
%35 = icmp eq i8 %34, 0
br i1 %35, label %47, label %36
36: ; preds = %33
%37 = tail call signext i8 (...) @read_u8()
store i8 %37, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 12)
%38 = icmp eq i8 %37, 0
br i1 %38, label %47, label %39
39: ; preds = %36
%40 = tail call signext i8 (...) @read_u8()
store i8 %40, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 13)
%41 = icmp eq i8 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %39
%43 = tail call signext i8 (...) @read_u8()
store i8 %43, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 14)
%44 = icmp eq i8 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = tail call signext i8 (...) @read_u8()
store i8 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 15)
br label %47
47: ; preds = %45, %3, %6, %9, %12, %15, %18, %21, %24, %27, %30, %33, %36, %39, %42, %0
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @read_str.str, i64 0, i64 0)
}