#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, int,
                           char *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
scalar_t__ match(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int read_swap_size(FILE *f) {
  int swap_size = 0;
  while (match(f, "Swap:")) {
    int i;
    do {
      if (!(fscanf(f, "%d", &i) == 1)) {
        fprintf(stderr, "\"%s\" failed in %s:%d (%s)\n",
                "fscanf(f, \"%d\", &i) == 1",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/nicball/playground/refs/"
                "heads/master/swapview.c",
                88, strerror(errno));
        exit(EXIT_FAILURE);
      }
    } while (false);
    swap_size += i;
  }
  return swap_size;
}


x86 assembly (clang, -O0):
<read_swap_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1050 <match@plt>
cmp    $0x0,%rax
je     1200 <read_swap_size+0xb0>
jmp    1182 <read_swap_size+0x32>
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <fscanf@plt>
cmp    $0x1,%eax
je     11ed <read_swap_size+0x9d>
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%r9
lea    0xe43(%rip),%rsi
lea    0xe57(%rip),%rdx
lea    0xe69(%rip),%rcx
mov    $0x58,%r8d
call   1040 <fprintf@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    11f2 <read_swap_size+0xa2>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <read_swap_size+0x13>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_swap_size>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe9a(%rip),%rsi
call   1050 <match@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11b7 <read_swap_size+0x67>
lea    0xe8d(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xe7b(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fscanf@plt>
cmp    $0x1,%eax
jne    11c6 <read_swap_size+0x76>
add    0xc(%rsp),%ebp
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <match@plt>
test   %rax,%rax
jne    1190 <read_swap_size+0x40>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e13(%rip),%rax
mov    (%rax),%ebx
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe25(%rip),%rsi
lea    0xe39(%rip),%rdx
lea    0xe4b(%rip),%rcx
mov    %ebx,%edi
mov    $0x58,%r8d
mov    %rax,%r9
call   1040 <fprintf@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"Swap:\00"
@.str.1 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.2 = [27 x i8] c"\22%s\22 failed in %s:%d (%s)\0A\00"
@.str.3 = [25 x i8] c"fscanf(f, \22%d\22, &i) == 1\00"
@.str.4 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nicball/playground/refs/heads/master/swapview.c\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @read_swap_size(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %22, %1
%6 = load i32*, i32** %2
%7 = call i64 @match(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %26
9: ; preds = %5
br label %10
10: ; preds = %9
%11 = load i32*, i32** %2
%12 = call i32 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%13 = icmp eq i32 %12, 1
br i1 %13, label %21, label %14
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
%18 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.4, i64 0, i64 0), i32 88, i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %10
br label %22
22: ; preds = %21
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = add nsw i32 %24, %23
store i32 %25, i32* %3
br label %5
26: ; preds = %5
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [6 x i8] c"Swap:\00"
@.str.1 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.2 = [27 x i8] c"\22%s\22 failed in %s:%d (%s)\0A\00"
@.str.3 = [25 x i8] c"fscanf(f, \22%d\22, &i) == 1\00"
@.str.4 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/nicball/playground/refs/heads/master/swapview.c\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @read_swap_size(i32* %0) {
%2 = alloca i32
%3 = call i64 @match(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %23, label %5
5: ; preds = %1
%6 = bitcast i32* %2 to i8*
br label %7
7: ; preds = %5, %18
%8 = phi i32 [ 0, %5 ], [ %20, %18 ]
%9 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = icmp eq i32 %9, 1
br i1 %10, label %18, label %11
11: ; preds = %7
%12 = load i32, i32* @stderr
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
%15 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.4, i64 0, i64 0), i32 88, i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %7
%19 = load i32, i32* %2
%20 = add nsw i32 %19, %8
%21 = call i64 @match(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %7
23: ; preds = %18, %1
%24 = phi i32 [ 0, %1 ], [ %20, %18 ]
ret i32 %24
}