#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*/ close(int);
int creat(char *, int);
int /*<<< orphan*/ doc_begin();
int /*<<< orphan*/ doc_end();
scalar_t__ errno;
int /*<<< orphan*/ first(char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int /*<<< orphan*/ result_begin();
int /*<<< orphan*/ result_end();
int /*<<< orphan*/ second(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int main(int argc, char *argv[]) {
  char buf[80 - 1];
  int j;
  int fd;
  doc_begin();
  result_begin();
  j = 0;
  for (int i = 0; i < 80; i++)
    buf[i] = 0;
  sprintf(buf, "tfile-%3.3d", j);
  fd = creat(buf, j);
  if (!(fd != -1)) {
    fprintf(stderr,
            "[ERROR] (%s:%d: errno: %s) "
            "creat(%s) failed"
            "\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/gulan/jecture/refs/heads/master/linux/"
            "chmod/main.c",
            76, (errno == 0 ? "None" : strerror(errno)), buf);
    errno = 0;
    goto error;
  };
  first(buf, j);
  close(fd);
  for (j = 1; j < 256; j++) {
    for (int i = 0; i < 80; i++)
      buf[i] = 0;
    sprintf(buf, "tfile-%3.3d", j);
    fd = creat(buf, j);
    if (!(fd != -1)) {
      fprintf(stderr,
              "[ERROR] (%s:%d: errno: %s) "
              "creat(%s) failed"
              "\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/gulan/jecture/refs/heads/master/linux/"
              "chmod/main.c",
              83, (errno == 0 ? "None" : strerror(errno)), buf);
      errno = 0;
      goto error;
    };
    second(buf, j);
    close(fd);
  }
  result_end();
  doc_end();
  return 0;
error:
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <doc_begin@plt>
mov    $0x0,%al
call   1040 <result_begin@plt>
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x6c(%rbp)
cmpl   $0x50,-0x6c(%rbp)
jge    1206 <main+0x56>
movslq -0x6c(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    11e5 <main+0x35>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%edx
lea    0xdec(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   10a0 <creat@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0xffffffff,-0x68(%rbp)
jne    12a8 <main+0xf8>
mov    0x2da7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    0x2d93(%rip),%rax
cmpq   $0x0,(%rax)
jne    125f <main+0xaf>
lea    0xe70(%rip),%rax
mov    %rax,-0x80(%rbp)
jmp    1272 <main+0xc2>
mov    0x2d72(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    %rax,-0x80(%rbp)
mov    -0x74(%rbp),%edi
mov    -0x80(%rbp),%r8
lea    -0x60(%rbp),%r9
lea    0xd88(%rip),%rsi
lea    0xdae(%rip),%rdx
mov    $0x4c,%ecx
call   1070 <fprintf@plt>
mov    0x2d3c(%rip),%rax
movq   $0x0,(%rax)
jmp    13e5 <main+0x235>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   10d0 <first@plt>
mov    -0x68(%rbp),%edi
call   1060 <close@plt>
movl   $0x1,-0x64(%rbp)
cmpl   $0x100,-0x64(%rbp)
jge    13cb <main+0x21b>
movl   $0x0,-0x70(%rbp)
cmpl   $0x50,-0x70(%rbp)
jge    12f8 <main+0x148>
movslq -0x70(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    12d7 <main+0x127>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%edx
lea    0xcfa(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   10a0 <creat@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0xffffffff,-0x68(%rbp)
jne    13a9 <main+0x1f9>
mov    0x2cb5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    0x2c9e(%rip),%rax
cmpq   $0x0,(%rax)
jne    1357 <main+0x1a7>
lea    0xd7b(%rip),%rax
mov    %rax,-0x90(%rbp)
jmp    136d <main+0x1bd>
mov    0x2c7a(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    %rax,-0x90(%rbp)
mov    -0x84(%rbp),%edi
mov    -0x90(%rbp),%r8
lea    -0x60(%rbp),%r9
lea    0xc87(%rip),%rsi
lea    0xcad(%rip),%rdx
mov    $0x53,%ecx
call   1070 <fprintf@plt>
mov    0x2c3b(%rip),%rax
movq   $0x0,(%rax)
jmp    13e5 <main+0x235>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1080 <second@plt>
mov    -0x68(%rbp),%edi
call   1060 <close@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    12c3 <main+0x113>
mov    $0x0,%al
call   1090 <result_end@plt>
mov    $0x0,%al
call   1030 <doc_end@plt>
movl   $0x0,-0x4(%rbp)
jmp    13ec <main+0x23c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
xor    %eax,%eax
call   1050 <doc_begin@plt>
xor    %eax,%eax
call   1040 <result_begin@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
lea    0xe16(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %edx,%edx
call   10b0 <sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <creat@plt>
cmp    $0xffffffff,%eax
je     129a <main+0xea>
mov    %eax,%ebp
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
call   10d0 <first@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    $0x1,%ebp
lea    0xdd4(%rip),%r14
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   10b0 <sprintf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   10a0 <creat@plt>
cmp    $0xffffffff,%eax
je     12bc <main+0x10c>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %ebp,%esi
call   1080 <second@plt>
mov    %ebx,%edi
call   1060 <close@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    1230 <main+0x80>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <result_end@plt>
xor    %eax,%eax
call   1030 <doc_end@plt>
jmp    1336 <main+0x186>
mov    0x2d3f(%rip),%rax
mov    (%rax),%ebx
mov    0x2d2e(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     12de <main+0x12e>
call   10c0 <strerror@plt>
mov    %rax,%r8
jmp    12e5 <main+0x135>
mov    0x2d1d(%rip),%rax
mov    (%rax),%ebx
mov    0x2d0c(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     12ff <main+0x14f>
call   10c0 <strerror@plt>
mov    %rax,%r8
jmp    1306 <main+0x156>
lea    0xde1(%rip),%r8
lea    0xd20(%rip),%rsi
lea    0xd46(%rip),%rdx
mov    %rsp,%r9
mov    %ebx,%edi
mov    $0x4c,%ecx
jmp    131e <main+0x16e>
lea    0xdc0(%rip),%r8
lea    0xcff(%rip),%rsi
lea    0xd25(%rip),%rdx
mov    %rsp,%r9
mov    %ebx,%edi
mov    $0x53,%ecx
call   1070 <fprintf@plt>
mov    0x2cae(%rip),%rax
movq   $0x0,(%rax)
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"tfile-%3.3d\00"
@stderr = global i32 0
@.str.1 = [45 x i8] c"[ERROR] (%s:%d: errno: %s) creat(%s) failed\0A\00"
@.str.2 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/gulan/jecture/refs/heads/master/linux/chmod/main.c\00"
@errno = global i64 0
@.str.3 = [5 x i8] c"None\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [79 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (...) @doc_begin()
%12 = call i32 (...) @result_begin()
store i32 0, i32* %7
store i32 0, i32* %9
br label %13
13: ; preds = %20, %2
%14 = load i32, i32* %9
%15 = icmp slt i32 %14, 80
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [79 x i8], [79 x i8]* %6, i64 0, i64 %18
store i8 0, i8* %19
br label %20
20: ; preds = %16
%21 = load i32, i32* %9
%22 = add nsw i32 %21, 1
store i32 %22, i32* %9
br label %13
23: ; preds = %13
%24 = getelementptr inbounds [79 x i8], [79 x i8]* %6, i64 0, i64 0
%25 = load i32, i32* %7
%26 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [79 x i8], [79 x i8]* %6, i64 0, i64 0
%28 = load i32, i32* %7
%29 = call i32 @creat(i8* %27, i32 %28)
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, -1
br i1 %31, label %44, label %32
32: ; preds = %23
%33 = load i32, i32* @stderr
%34 = load i64, i64* @errno
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
br label %40
37: ; preds = %32
%38 = load i64, i64* @errno
%39 = call i8* @strerror(i64 %38)
br label %40
40: ; preds = %37, %36
%41 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %36 ], [ %39, %37 ]
%42 = getelementptr inbounds [79 x i8], [79 x i8]* %6, i64 0, i64 0
%43 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.2, i64 0, i64 0), i32 76, i8* %41, i8* %42)
store i64 0, i64* @errno
br label %97
44: ; preds = %23
%45 = getelementptr inbounds [79 x i8], [79 x i8]* %6, i64 0, i64 0
%46 = load i32, i32* %7
%47 = call i32 @first(i8* %45, i32 %46)
%48 = load i32, i32* %8
%49 = call i32 @close(i32 %48)
store i32 1, i32* %7
br label %50
50: ; preds = %91, %44
%51 = load i32, i32* %7
%52 = icmp slt i32 %51, 256
br i1 %52, label %53, label %94
53: ; preds = %50
store i32 0, i32* %10
br label %54
54: ; preds = %61, %53
%55 = load i32, i32* %10
%56 = icmp slt i32 %55, 80
br i1 %56, label %57, label %64
57: ; preds = %54
%58 = load i32, i32* %10
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [79 x i8], [79 x i8]* %6, i64 0, i64 %59
store i8 0, i8* %60
br label %61
61: ; preds = %57
%62 = load i32, i32* %10
%63 = add nsw i32 %62, 1
store i32 %63, i32* %10
br label %54
64: ; preds = %54
%65 = getelementptr inbounds [79 x i8], [79 x i8]* %6, i64 0, i64 0
%66 = load i32, i32* %7
%67 = call i32 @sprintf(i8* %65, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %66)
%68 = getelementptr inbounds [79 x i8], [79 x i8]* %6, i64 0, i64 0
%69 = load i32, i32* %7
%70 = call i32 @creat(i8* %68, i32 %69)
store i32 %70, i32* %8
%71 = load i32, i32* %8
%72 = icmp ne i32 %71, -1
br i1 %72, label %85, label %73
73: ; preds = %64
%74 = load i32, i32* @stderr
%75 = load i64, i64* @errno
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %73
br label %81
78: ; preds = %73
%79 = load i64, i64* @errno
%80 = call i8* @strerror(i64 %79)
br label %81
81: ; preds = %78, %77
%82 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %77 ], [ %80, %78 ]
%83 = getelementptr inbounds [79 x i8], [79 x i8]* %6, i64 0, i64 0
%84 = call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.2, i64 0, i64 0), i32 83, i8* %82, i8* %83)
store i64 0, i64* @errno
br label %97
85: ; preds = %64
%86 = getelementptr inbounds [79 x i8], [79 x i8]* %6, i64 0, i64 0
%87 = load i32, i32* %7
%88 = call i32 @second(i8* %86, i32 %87)
%89 = load i32, i32* %8
%90 = call i32 @close(i32 %89)
br label %91
91: ; preds = %85
%92 = load i32, i32* %7
%93 = add nsw i32 %92, 1
store i32 %93, i32* %7
br label %50
94: ; preds = %50
%95 = call i32 (...) @result_end()
%96 = call i32 (...) @doc_end()
store i32 0, i32* %3
br label %98
97: ; preds = %81, %40
store i32 1, i32* %3
br label %98
98: ; preds = %97, %94
%99 = load i32, i32* %3
ret i32 %99
}

LLVM IR (-O2):
@.str = [12 x i8] c"tfile-%3.3d\00"
@stderr = global i32 0
@.str.1 = [45 x i8] c"[ERROR] (%s:%d: errno: %s) creat(%s) failed\0A\00"
@.str.2 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/gulan/jecture/refs/heads/master/linux/chmod/main.c\00"
@errno = global i64 0
@.str.3 = [5 x i8] c"None\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [79 x i8]
%4 = getelementptr inbounds [79 x i8], [79 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [79 x i8], [79 x i8]* %3, i64 0, i64 0
%6 = tail call i32 (...) @doc_begin()
%7 = tail call i32 (...) @result_begin()
%8 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
%9 = call i32 @creat(i8* %5, i32 0)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i64, i64* @errno
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = call i8* @strerror(i64 %13)
br label %17
17: ; preds = %11, %15
%18 = phi i8* [ %16, %15 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %11 ]
%19 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.2, i64 0, i64 0), i32 76, i8* %18, i8* %5)
br label %45
20: ; preds = %2
%21 = call i32 @first(i8* %5, i32 0)
%22 = call i32 @close(i32 %9)
br label %23
23: ; preds = %20, %37
%24 = phi i32 [ 1, %20 ], [ %40, %37 ]
%25 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = call i32 @creat(i8* %5, i32 %24)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %37
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = load i64, i64* @errno
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = call i8* @strerror(i64 %30)
br label %34
34: ; preds = %28, %32
%35 = phi i8* [ %33, %32 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %28 ]
%36 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.2, i64 0, i64 0), i32 83, i8* %35, i8* %5)
br label %45
37: ; preds = %23
%38 = call i32 @second(i8* %5, i32 %24)
%39 = call i32 @close(i32 %26)
%40 = add nuw nsw i32 %24, 1
%41 = icmp eq i32 %40, 256
br i1 %41, label %42, label %23
42: ; preds = %37
%43 = call i32 (...) @result_end()
%44 = call i32 (...) @doc_end()
br label %46
45: ; preds = %34, %17
store i64 0, i64* @errno
br label %46
46: ; preds = %45, %42
%47 = phi i32 [ 1, %45 ], [ 0, %42 ]
ret i32 %47
}