#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 */
struct string {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ check_magic(int /*<<< orphan*/ *);
scalar_t__ decode_string(int /*<<< orphan*/ *, struct string **);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error_at_line(int, int /*<<< orphan*/, char *, int, char *,
                                 ...);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ header_check(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_string(struct string *, int /*<<< orphan*/);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  if (argc < 2) {
    do {
      fprintf(stderr, "usage: %s <filename>", argc ? argv[0] : "gkr-decrypt");
      putc('\n', stderr);
    } while (0);
    return 1;
  }
  const char *fname = argv[1];
  FILE *f = fopen(fname, "rb");
  if (!f) {
    error_at_line(1, errno,
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/jmesmon/trifles/refs/"
                  "heads/master/gkr-decrypt.c",
                  157, "on fopen of \"%s\"", fname);
  }
  if (check_magic(f) < 0)
    return 1;
  if (header_check(f) < 0)
    return 1;
  struct string *keyring_name;
  if (decode_string(f, &keyring_name) < 0)
    error_at_line(1, errno,
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/jmesmon/trifles/refs/"
                  "heads/master/gkr-decrypt.c",
                  169, "failed to decode keyring name");
  fputs("keyring name: ", stdout);
  print_string(keyring_name, stdout);
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    122d <main+0x8d>
jmp    11c5 <main+0x25>
mov    0x2e14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11eb <main+0x4b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    11fb <main+0x5b>
lea    0xe23(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    11fb <main+0x5b>
mov    -0x2c(%rbp),%edi
mov    -0x38(%rbp),%rdx
lea    0xdf7(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1080 <putc@plt>
movl   $0x1,-0x4(%rbp)
jmp    1339 <main+0x199>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xddd(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1284 <main+0xe4>
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%r9
mov    $0x1,%edi
lea    0xdb3(%rip),%rdx
mov    $0x9d,%ecx
lea    0xe31(%rip),%r8
mov    $0x0,%al
call   1040 <error_at_line@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <check_magic@plt>
cmp    $0x0,%rax
jge    12a3 <main+0x103>
movl   $0x1,-0x4(%rbp)
jmp    1339 <main+0x199>
mov    -0x20(%rbp),%rdi
call   1050 <header_check@plt>
cmp    $0x0,%rax
jge    12c2 <main+0x122>
movl   $0x1,-0x4(%rbp)
jmp    1339 <main+0x199>
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   10b0 <decode_string@plt>
cmp    $0x0,%rax
jge    1301 <main+0x161>
mov    0x2cf8(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xd36(%rip),%rdx
mov    $0xa9,%ecx
lea    0xdc5(%rip),%r8
mov    $0x0,%al
call   1040 <error_at_line@plt>
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
lea    0xdcc(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x28(%rbp),%rdi
mov    0x2caf(%rip),%rax
mov    (%rax),%esi
call   1070 <print_string@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jg     11c8 <main+0x28>
mov    %edi,%eax
mov    0x2e2a(%rip),%rbx
mov    (%rbx),%edi
test   %eax,%eax
je     129e <main+0xfe>
mov    (%rsi),%rdx
jmp    12a5 <main+0x105>
mov    0x8(%rsi),%r14
lea    0xe4e(%rip),%rsi
mov    %r14,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    120e <main+0x6e>
mov    0x2dee(%rip),%rax
mov    (%rax),%esi
lea    0xe31(%rip),%rdx
lea    0xeb4(%rip),%r8
mov    $0x1,%edi
mov    $0x9d,%ecx
mov    %r14,%r9
xor    %eax,%eax
call   1040 <error_at_line@plt>
mov    %rbx,%rdi
call   10c0 <check_magic@plt>
mov    $0x1,%ebp
test   %rax,%rax
js     12c2 <main+0x122>
mov    %rbx,%rdi
call   1050 <header_check@plt>
test   %rax,%rax
js     12c2 <main+0x122>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   10b0 <decode_string@plt>
test   %rax,%rax
jns    126f <main+0xcf>
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
lea    0xdcd(%rip),%rdx
lea    0xe61(%rip),%r8
mov    $0x1,%edi
mov    $0xa9,%ecx
xor    %eax,%eax
call   1040 <error_at_line@plt>
mov    0x2d5a(%rip),%rbx
mov    (%rbx),%esi
lea    0xe5e(%rip),%rdi
call   1060 <fputs@plt>
mov    0x8(%rsp),%rdi
mov    (%rbx),%esi
call   1070 <print_string@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    12c2 <main+0x122>
lea    0xd70(%rip),%rdx
lea    0xd54(%rip),%rsi
call   1090 <fprintf@plt>
mov    (%rbx),%esi
mov    $0xa,%edi
call   1080 <putc@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.string = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"usage: %s <filename>\00"
@.str.1 = [12 x i8] c"gkr-decrypt\00"
@.str.2 = [3 x i8] c"rb\00"
@errno = global i32 0
@.str.3 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jmesmon/trifles/refs/heads/master/gkr-decrypt.c\00"
@.str.4 = [17 x i8] c"on fopen of \22%s\22\00"
@.str.5 = [30 x i8] c"failed to decode keyring name\00"
@.str.6 = [15 x i8] c"keyring name: \00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca %struct.string*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %27
11: ; preds = %2
br label %12
12: ; preds = %11
%13 = load i32, i32* @stderr
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
br label %21
20: ; preds = %12
br label %21
21: ; preds = %20, %16
%22 = phi i8* [ %19, %16 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %20 ]
%23 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @stderr
%25 = call i32 @putc(i8 signext 10, i32 %24)
br label %26
26: ; preds = %21
store i32 1, i32* %3
br label %63
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
store i8* %30, i8** %6
%31 = load i8*, i8** %6
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %32, i32** %7
%33 = load i32*, i32** %7
%34 = icmp ne i32* %33, null
br i1 %34, label %39, label %35
35: ; preds = %27
%36 = load i32, i32* @errno
%37 = load i8*, i8** %6
%38 = call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 1, i32 %36, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.3, i64 0, i64 0), i32 157, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %35, %27
%40 = load i32*, i32** %7
%41 = call i64 @check_magic(i32* %40)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
store i32 1, i32* %3
br label %63
44: ; preds = %39
%45 = load i32*, i32** %7
%46 = call i64 @header_check(i32* %45)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44
store i32 1, i32* %3
br label %63
49: ; preds = %44
%50 = load i32*, i32** %7
%51 = call i64 @decode_string(i32* %50, %struct.string** %8)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = load i32, i32* @errno
%55 = call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 1, i32 %54, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.3, i64 0, i64 0), i32 169, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %56
56: ; preds = %53, %49
%57 = load i32, i32* @stdout
%58 = call i32 @fputs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %57)
%59 = load %struct.string*, %struct.string** %8
%60 = load i32, i32* @stdout
%61 = call i32 @print_string(%struct.string* %59, i32 %60)
%62 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %3
br label %63
63: ; preds = %56, %48, %43, %26
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
%struct.string = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"usage: %s <filename>\00"
@.str.1 = [12 x i8] c"gkr-decrypt\00"
@.str.2 = [3 x i8] c"rb\00"
@errno = global i32 0
@.str.3 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jmesmon/trifles/refs/heads/master/gkr-decrypt.c\00"
@.str.4 = [17 x i8] c"on fopen of \22%s\22\00"
@.str.5 = [30 x i8] c"failed to decode keyring name\00"
@.str.6 = [15 x i8] c"keyring name: \00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.string*
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = icmp eq i32 %0, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = load i8*, i8** %1
br label %10
10: ; preds = %5, %8
%11 = phi i8* [ %9, %8 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %5 ]
%12 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @stderr
%14 = tail call i32 @putc(i8 signext 10, i32 %13)
br label %43
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* @errno
%22 = tail call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 1, i32 %21, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.3, i64 0, i64 0), i32 157, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %17)
br label %23
23: ; preds = %20, %15
%24 = tail call i64 @check_magic(i32* %18)
%25 = icmp slt i64 %24, 0
br i1 %25, label %43, label %26
26: ; preds = %23
%27 = tail call i64 @header_check(i32* %18)
%28 = icmp slt i64 %27, 0
br i1 %28, label %43, label %29
29: ; preds = %26
%30 = bitcast %struct.string** %3 to i8*
%31 = call i64 @decode_string(i32* %18, %struct.string** %3)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* @errno
%35 = call i32 (i32, i32, i8*, i32, i8*, ...) @error_at_line(i32 1, i32 %34, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.3, i64 0, i64 0), i32 169, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %33, %29
%37 = load i32, i32* @stdout
%38 = call i32 @fputs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %37)
%39 = load %struct.string*, %struct.string** %3
%40 = load i32, i32* @stdout
%41 = call i32 @print_string(%struct.string* %39, i32 %40)
%42 = call i32 @putchar(i8 signext 10)
br label %43
43: ; preds = %36, %23, %26, %10
%44 = phi i32 [ 1, %10 ], [ 0, %36 ], [ 1, %23 ], [ 1, %26 ]
ret i32 %44
}