#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*/ free(char *);
char *malloc_or_die(int);
int /*<<< orphan*/ my_strcat(char *, char *);
int /*<<< orphan*/ print_fatal_error(int);
int read(int /*<<< orphan*/, char *, int);
char *get_expr(unsigned int size) {
  char *expr;
  char *buffer;
  int ret;
  unsigned long c;
  int buff_s;
  buff_s = 9990000;
  if (size < 9990000)
    buff_s = size;
  c = 0;
  ret = 0;
  if (size <= 1)
    print_fatal_error(2);
  buffer = malloc_or_die(sizeof(char) * buff_s + 1);
  expr = malloc_or_die(sizeof(char) * size + 1);
  expr[0] = 0;
  buffer[0] = 0;
  while (c < size) {
    ret = read(0, buffer, buff_s - 1);
    if (ret == -1)
      print_fatal_error(4);
    else if (ret == 0)
      break;
    buffer[ret] = 0;
    c = c + ret;
    my_strcat(expr, buffer);
  }
  expr[size] = 0;
  free(buffer);
  return (expr);
}


x86 assembly (clang, -O0):
<get_expr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x986f70,-0x2c(%rbp)
cmpl   $0x986f70,-0x4(%rbp)
jae    1175 <get_expr+0x25>
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x4(%rbp)
ja     1198 <get_expr+0x48>
mov    $0x2,%edi
call   1040 <print_fatal_error@plt>
movslq -0x2c(%rbp),%rax
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1070 <malloc_or_die@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1070 <malloc_or_die@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
mov    -0x4(%rbp),%ecx
cmp    %rcx,%rax
jae    1251 <get_expr+0x101>
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
sub    $0x1,%edx
xor    %edi,%edi
call   1050 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1210 <get_expr+0xc0>
mov    $0x4,%edi
call   1040 <print_fatal_error@plt>
jmp    1224 <get_expr+0xd4>
cmpl   $0x0,-0x1c(%rbp)
jne    121f <get_expr+0xcf>
jmp    1251 <get_expr+0x101>
jmp    1224 <get_expr+0xd4>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <my_strcat@plt>
jmp    11d3 <get_expr+0x83>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_expr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x986f70,%edi
mov    $0x986f70,%r14d
cmovb  %edi,%r14d
cmp    $0x1,%edi
ja     117c <get_expr+0x2c>
mov    $0x2,%edi
call   1040 <print_fatal_error@plt>
lea    0x1(%r14),%edi
call   1070 <malloc_or_die@plt>
mov    %rax,%r12
mov    %ebx,%r13d
lea    0x1(%rbx),%edi
call   1070 <malloc_or_die@plt>
mov    %rax,%r15
movb   $0x0,(%rax)
movb   $0x0,(%r12)
test   %ebx,%ebx
je     11ed <get_expr+0x9d>
add    $0xffffffff,%r14d
xor    %ebx,%ebx
jmp    11d5 <get_expr+0x85>
nopw   0x0(%rax,%rax,1)
mov    $0x4,%edi
call   1040 <print_fatal_error@plt>
movslq %ebp,%rax
movb   $0x0,(%r12,%rax,1)
add    %rax,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <my_strcat@plt>
cmp    %r13,%rbx
jae    11ed <get_expr+0x9d>
xor    %edi,%edi
mov    %r12,%rsi
mov    %r14d,%edx
call   1050 <read@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     11b0 <get_expr+0x60>
test   %ebp,%ebp
jne    11ba <get_expr+0x6a>
movb   $0x0,(%r15,%r13,1)
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @get_expr(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
store i32 %0, i32* %2
store i32 9990000, i32* %7
%8 = load i32, i32* %2
%9 = icmp ult i32 %8, 9990000
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load i32, i32* %2
store i32 %11, i32* %7
br label %12
12: ; preds = %10, %1
store i64 0, i64* %6
store i32 0, i32* %5
%13 = load i32, i32* %2
%14 = icmp ule i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @print_fatal_error(i32 2)
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = mul i64 1, %19
%21 = add i64 %20, 1
%22 = trunc i64 %21 to i32
%23 = call i8* @malloc_or_die(i32 %22)
store i8* %23, i8** %4
%24 = load i32, i32* %2
%25 = zext i32 %24 to i64
%26 = mul i64 1, %25
%27 = add i64 %26, 1
%28 = trunc i64 %27 to i32
%29 = call i8* @malloc_or_die(i32 %28)
store i8* %29, i8** %3
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 0
store i8 0, i8* %31
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 0
store i8 0, i8* %33
br label %34
34: ; preds = %53, %17
%35 = load i64, i64* %6
%36 = load i32, i32* %2
%37 = zext i32 %36 to i64
%38 = icmp ult i64 %35, %37
br i1 %38, label %39, label %65
39: ; preds = %34
%40 = load i8*, i8** %4
%41 = load i32, i32* %7
%42 = sub nsw i32 %41, 1
%43 = call i32 @read(i32 0, i8* %40, i32 %42)
store i32 %43, i32* %5
%44 = load i32, i32* %5
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %48
46: ; preds = %39
%47 = call i32 @print_fatal_error(i32 4)
br label %53
48: ; preds = %39
%49 = load i32, i32* %5
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %48
br label %65
52: ; preds = %48
br label %53
53: ; preds = %52, %46
%54 = load i8*, i8** %4
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
store i8 0, i8* %57
%58 = load i64, i64* %6
%59 = load i32, i32* %5
%60 = sext i32 %59 to i64
%61 = add i64 %58, %60
store i64 %61, i64* %6
%62 = load i8*, i8** %3
%63 = load i8*, i8** %4
%64 = call i32 @my_strcat(i8* %62, i8* %63)
br label %34
65: ; preds = %51, %34
%66 = load i8*, i8** %3
%67 = load i32, i32* %2
%68 = zext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %66, i64 %68
store i8 0, i8* %69
%70 = load i8*, i8** %4
%71 = call i32 @free(i8* %70)
%72 = load i8*, i8** %3
ret i8* %72
}

LLVM IR (-O2):
define i8* @get_expr(i32 %0) {
%2 = icmp ult i32 %0, 9990000
%3 = select i1 %2, i32 %0, i32 9990000
%4 = icmp ult i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @print_fatal_error(i32 2)
br label %7
7: ; preds = %5, %1
%8 = add nuw nsw i32 %3, 1
%9 = tail call i8* @malloc_or_die(i32 %8)
%10 = zext i32 %0 to i64
%11 = add i32 %0, 1
%12 = tail call i8* @malloc_or_die(i32 %11)
store i8 0, i8* %12
store i8 0, i8* %9
%13 = icmp eq i32 %0, 0
br i1 %13, label %27, label %14
14: ; preds = %7
%15 = add nsw i32 %3, -1
br label %16
16: ; preds = %14, %21
%17 = phi i64 [ 0, %14 ], [ %24, %21 ]
%18 = tail call i32 @read(i32 0, i8* %9, i32 %15)
switch i32 %18, label %21 [
i32 -1, label %19
i32 0, label %27
]
19: ; preds = %16
%20 = tail call i32 @print_fatal_error(i32 4)
br label %21
21: ; preds = %16, %19
%22 = sext i32 %18 to i64
%23 = getelementptr inbounds i8, i8* %9, i64 %22
store i8 0, i8* %23
%24 = add i64 %17, %22
%25 = tail call i32 @my_strcat(i8* %12, i8* %9)
%26 = icmp ult i64 %24, %10
br i1 %26, label %16, label %27
27: ; preds = %21, %16, %7
%28 = getelementptr inbounds i8, i8* %12, i64 %10
store i8 0, i8* %28
%29 = tail call i32 @free(i8* %9)
ret i8* %12
}