#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 BUFSIZ;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int read(int, char *, int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ write(int, char *, int);
void showdata(char *fname, int fd) {
  char buf[BUFSIZ];
  int n;
  printf("%s: %d", fname, n);
  fflush(stdout);
  n = read(fd, buf, BUFSIZ);
  if (n == -1) {
    perror(fname);
    exit(5);
  };
  write(1, buf, n);
  write(1, "\n", 1);
}


x86 assembly (clang, -O0):
<showdata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%edi
mov    0x2e16(%rip),%rax
mov    (%rax),%edx
call   1050 <read@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    11f1 <showdata+0x91>
mov    -0x8(%rbp),%rdi
call   1070 <perror@plt>
mov    $0x5,%edi
call   1080 <exit@plt>
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xdf9(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showdata>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
mov    0x2e68(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe6c(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    (%r12),%edx
mov    %r15d,%edi
mov    %rbx,%rsi
call   1050 <read@plt>
cmp    $0xffffffff,%eax
je     11ef <showdata+0x8f>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe33(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <write@plt>
mov    %r14,%rdi
call   1070 <perror@plt>
mov    $0x5,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [7 x i8] c"%s: %d\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define void @showdata(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i32, i32* @BUFSIZ
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %5
%11 = alloca i8, i64 %9
store i64 %9, i64* %6
%12 = load i8*, i8** %3
%13 = load i32, i32* %7
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %13)
%15 = load i32, i32* @stdout
%16 = call i32 @fflush(i32 %15)
%17 = load i32, i32* %4
%18 = load i32, i32* @BUFSIZ
%19 = call i32 @read(i32 %17, i8* %11, i32 %18)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i8*, i8** %3
%24 = call i32 @perror(i8* %23)
%25 = call i32 @exit(i32 5)
unreachable
26: ; preds = %2
%27 = load i32, i32* %7
%28 = call i32 @write(i32 1, i8* %11, i32 %27)
%29 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%30 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [7 x i8] c"%s: %d\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define void @showdata(i8* %0, i32 %1) {
%3 = load i32, i32* @BUFSIZ
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0, i32 undef)
%7 = load i32, i32* @stdout
%8 = tail call i32 @fflush(i32 %7)
%9 = load i32, i32* @BUFSIZ
%10 = call i32 @read(i32 %1, i8* %5, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = tail call i32 @perror(i8* %0)
%14 = tail call i32 @exit(i32 5)
unreachable
15: ; preds = %2
%16 = call i32 @write(i32 1, i8* %5, i32 %10)
%17 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
ret void
}