#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_FAILURE;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
scalar_t__ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ putchar(char);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void echo_file(int fd, const char *prefix) {
  char buffer[BUFSIZ];
  int indent, n, i;
  indent = 1;
  do {
    if (!(lseek(fd, 0, SEEK_SET) == 0)) {
      fprintf(stderr, "%s,%d \"%s\": %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/cventus/otivm/refs/heads/master/src/"
              "ok/posix/run_test.c",
              114, "lseek(fd, 0, SEEK_SET) == 0", strerror(errno));
      exit(EXIT_FAILURE);
    }
  } while (0);
  while (n = read(fd, buffer, sizeof buffer), n > 0) {
    if (indent)
      printf("%s", prefix);
    for (i = 0; i < n - 1; i++) {
      putchar(buffer[i]);
      if (buffer[i] == '\n')
        printf("%s", prefix);
    }
    putchar(buffer[n - 1]);
    indent = (buffer[n - 1] == '\n');
  }
  do {
    if (!(n == 0)) {
      fprintf(stderr, "%s,%d \"%s\": %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/cventus/otivm/refs/heads/master/src/"
              "ok/posix/run_test.c",
              124, "n == 0", strerror(errno));
      exit(EXIT_FAILURE);
    }
  } while (0);
}


x86 assembly (clang, -O0):
<echo_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x40(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e08(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
cmp    $0x0,%rax
je     1220 <echo_file+0xb0>
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%r9
lea    0xe06(%rip),%rsi
lea    0xe0f(%rip),%rdx
mov    $0x72,%ecx
lea    0xe95(%rip),%r8
call   1070 <fprintf@plt>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1225 <echo_file+0xb5>
jmp    122a <echo_file+0xba>
jmp    122f <echo_file+0xbf>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rax
mov    -0x4(%rbp),%edi
mov    %eax,%edx
call   1060 <read@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    1303 <echo_file+0x193>
cmpl   $0x0,-0x24(%rbp)
je     1268 <echo_file+0xf8>
mov    -0x10(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12c9 <echo_file+0x159>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    12b6 <echo_file+0x146>
mov    -0x10(%rbp),%rsi
lea    0xe0d(%rip),%rdi
call   1040 <printf@plt>
jmp    12bb <echo_file+0x14b>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    126f <echo_file+0xff>
mov    -0x38(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
jmp    122f <echo_file+0xbf>
jmp    1308 <echo_file+0x198>
cmpl   $0x0,-0x28(%rbp)
je     135f <echo_file+0x1ef>
mov    0x2cc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%r9
lea    0xcc7(%rip),%rsi
lea    0xcd0(%rip),%rdx
mov    $0x7c,%ecx
lea    0xd75(%rip),%r8
call   1070 <fprintf@plt>
mov    0x2c68(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1364 <echo_file+0x1f4>
jmp    1369 <echo_file+0x1f9>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<echo_file>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r12
mov    %edi,%r13d
mov    0x2e4a(%rip),%rax
mov    (%rax),%ebx
mov    %rsp,%r15
lea    0xf(%rbx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    0x2e20(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
test   %rax,%rax
jne    128f <echo_file+0x11f>
mov    %r13d,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1060 <read@plt>
mov    %eax,%r14d
test   %eax,%eax
jle    127b <echo_file+0x10b>
mov    %rbx,-0x40(%rbp)
mov    $0x1,%ebx
mov    %r13d,-0x2c(%rbp)
jmp    121c <echo_file+0xac>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x38(%rbp),%rax
movsbl (%r15,%rax,1),%edi
xor    %ebx,%ebx
cmp    $0xa,%edi
sete   %bl
call   1030 <putchar@plt>
mov    -0x2c(%rbp),%edi
mov    %r15,%rsi
mov    -0x40(%rbp),%rdx
call   1060 <read@plt>
mov    %eax,%r14d
test   %eax,%eax
jle    127b <echo_file+0x10b>
test   %ebx,%ebx
je     122f <echo_file+0xbf>
lea    0xe97(%rip),%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
movslq %r14d,%rax
lea    -0x1(%rax),%rcx
mov    %rcx,-0x38(%rbp)
cmp    $0x2,%eax
jb     11f0 <echo_file+0x80>
mov    -0x38(%rbp),%r14d
xor    %r13d,%r13d
jmp    1259 <echo_file+0xe9>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    %r13,%r14
je     11f0 <echo_file+0x80>
movsbl (%r15,%r13,1),%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
cmp    $0xa,%ebx
jne    1250 <echo_file+0xe0>
lea    0xe4d(%rip),%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
jmp    1250 <echo_file+0xe0>
test   %r14d,%r14d
jne    12c4 <echo_file+0x154>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d4a(%rip),%rax
mov    (%rax),%ebx
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xd53(%rip),%rsi
lea    0xd5c(%rip),%rdx
lea    0xde7(%rip),%r8
mov    %ebx,%edi
mov    $0x72,%ecx
jmp    12f7 <echo_file+0x187>
mov    0x2d15(%rip),%rax
mov    (%rax),%ebx
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xd1e(%rip),%rsi
lea    0xd27(%rip),%rdx
lea    0xdd1(%rip),%r8
mov    %ebx,%edi
mov    $0x7c,%ecx
mov    %rax,%r9
call   1070 <fprintf@plt>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"%s,%d \22%s\22: %s\0A\00"
@.str.1 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/cventus/otivm/refs/heads/master/src/ok/posix/run_test.c\00"
@.str.2 = [28 x i8] c"lseek(fd, 0, SEEK_SET) == 0\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [7 x i8] c"n == 0\00"
define void @echo_file(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%10 = load i32, i32* @BUFSIZ
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %5
%13 = alloca i8, i64 %11
store i64 %11, i64* %6
store i32 1, i32* %7
br label %14
14: ; preds = %2
%15 = load i32, i32* %3
%16 = load i32, i32* @SEEK_SET
%17 = call i64 @lseek(i32 %15, i32 0, i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = call i8* @strerror(i32 %21)
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 114, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %14
br label %27
27: ; preds = %26
br label %28
28: ; preds = %27
br label %29
29: ; preds = %66, %28
%30 = load i32, i32* %3
%31 = trunc i64 %11 to i32
%32 = call i32 @read(i32 %30, i8* %13, i32 %31)
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %81
35: ; preds = %29
%36 = load i32, i32* %7
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i8*, i8** %4
%40 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %38, %35
store i32 0, i32* %9
br label %42
42: ; preds = %63, %41
%43 = load i32, i32* %9
%44 = load i32, i32* %8
%45 = sub nsw i32 %44, 1
%46 = icmp slt i32 %43, %45
br i1 %46, label %47, label %66
47: ; preds = %42
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %13, i64 %49
%51 = load i8, i8* %50
%52 = call i32 @putchar(i8 signext %51)
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %13, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 10
br i1 %58, label %59, label %62
59: ; preds = %47
%60 = load i8*, i8** %4
%61 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %59, %47
br label %63
63: ; preds = %62
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
store i32 %65, i32* %9
br label %42
66: ; preds = %42
%67 = load i32, i32* %8
%68 = sub nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %13, i64 %69
%71 = load i8, i8* %70
%72 = call i32 @putchar(i8 signext %71)
%73 = load i32, i32* %8
%74 = sub nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %13, i64 %75
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 10
%80 = zext i1 %79 to i32
store i32 %80, i32* %7
br label %29
81: ; preds = %29
br label %82
82: ; preds = %81
%83 = load i32, i32* %8
%84 = icmp eq i32 %83, 0
br i1 %84, label %92, label %85
85: ; preds = %82
%86 = load i32, i32* @stderr
%87 = load i32, i32* @errno
%88 = call i8* @strerror(i32 %87)
%89 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 124, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %88)
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %82
br label %93
93: ; preds = %92
br label %94
94: ; preds = %93
%95 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"%s,%d \22%s\22: %s\0A\00"
@.str.1 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/cventus/otivm/refs/heads/master/src/ok/posix/run_test.c\00"
@.str.2 = [28 x i8] c"lseek(fd, 0, SEEK_SET) == 0\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [7 x i8] c"n == 0\00"
define void @echo_file(i32 %0, i8* %1) {
%3 = load i32, i32* @BUFSIZ
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = load i32, i32* @SEEK_SET
%7 = tail call i64 @lseek(i32 %0, i32 0, i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 @read(i32 %0, i8* %5, i32 %3)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %19, label %50
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i32, i32* @errno
%15 = tail call i8* @strerror(i32 %14)
%16 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 114, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = tail call i32 @exit(i32 %17)
unreachable
19: ; preds = %9, %41
%20 = phi i32 [ %48, %41 ], [ %10, %9 ]
%21 = phi i32 [ %47, %41 ], [ 1, %9 ]
%22 = icmp eq i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %25
25: ; preds = %23, %19
%26 = add nsw i32 %20, -1
%27 = icmp ugt i32 %20, 1
br i1 %27, label %28, label %41
28: ; preds = %25
%29 = zext i32 %26 to i64
br label %30
30: ; preds = %28, %38
%31 = phi i64 [ 0, %28 ], [ %39, %38 ]
%32 = getelementptr inbounds i8, i8* %5, i64 %31
%33 = load i8, i8* %32
%34 = tail call i32 @putchar(i8 signext %33)
%35 = icmp eq i8 %33, 10
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %38
38: ; preds = %30, %36
%39 = add nuw nsw i64 %31, 1
%40 = icmp eq i64 %39, %29
br i1 %40, label %41, label %30
41: ; preds = %38, %25
%42 = sext i32 %26 to i64
%43 = getelementptr inbounds i8, i8* %5, i64 %42
%44 = load i8, i8* %43
%45 = tail call i32 @putchar(i8 signext %44)
%46 = icmp eq i8 %44, 10
%47 = zext i1 %46 to i32
%48 = call i32 @read(i32 %0, i8* %5, i32 %3)
%49 = icmp sgt i32 %48, 0
br i1 %49, label %19, label %50
50: ; preds = %41, %9
%51 = phi i32 [ %10, %9 ], [ %48, %41 ]
%52 = icmp eq i32 %51, 0
br i1 %52, label %60, label %53
53: ; preds = %50
%54 = load i32, i32* @stderr
%55 = load i32, i32* @errno
%56 = tail call i8* @strerror(i32 %55)
%57 = tail call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 124, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %56)
%58 = load i32, i32* @EXIT_FAILURE
%59 = tail call i32 @exit(i32 %58)
unreachable
60: ; preds = %50
ret void
}