#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 as_read(char *, int);
int as_read_to_file(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int exec_read(void *data) {
  char buf[256] = {0};
  int rc;
  rc = as_read(buf, 2);
  if (rc != -1) {
    printf("Received: %s\n", buf);
  }
  rc = as_read_to_file("some_file.txt", 200);
  return 200;
}


x86 assembly (clang, -O0):
<exec_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x110(%rbp),%rdi
mov    $0x2,%esi
call   1060 <as_read@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0xffffffff,-0x114(%rbp)
je     1199 <exec_read+0x59>
lea    -0x110(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe6e(%rip),%rdi
mov    $0xc8,%esi
call   1030 <as_read_to_file@plt>
mov    %eax,-0x114(%rbp)
mov    $0xc8,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exec_read>:
sub    $0x108,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x2,%esi
call   1050 <as_read@plt>
cmp    $0xffffffff,%eax
je     11c2 <exec_read+0x92>
lea    0xe46(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
lea    0xe45(%rip),%rdi
mov    $0xc8,%esi
call   1030 <as_read_to_file@plt>
mov    $0xc8,%eax
add    $0x108,%rsp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Received: %s\0A\00"
@.str.1 = [14 x i8] c"some_file.txt\00"
define i32 @exec_read(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i32
store i8* %0, i8** %2
%5 = bitcast [256 x i8]* %3 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = call i32 @as_read(i8* %6, i32 2)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %1
%14 = call i32 @as_read_to_file(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 200)
store i32 %14, i32* %4
ret i32 200
}

LLVM IR (-O2):
@.str = [14 x i8] c"Received: %s\0A\00"
@.str.1 = [14 x i8] c"some_file.txt\00"
define i32 @exec_read(i8* nocapture readnone %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @as_read(i8* %3, i32 2)
%5 = icmp eq i32 %4, -1
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %8
8: ; preds = %6, %1
%9 = call i32 @as_read_to_file(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 200)
ret i32 200
}