#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 EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ get_fucks(int /*<<< orphan*/ *, unsigned long *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ store_fucks(int /*<<< orphan*/ *, unsigned long *);
int main(void) {
  unsigned long fucks;
  FILE *fp;
  fp = fopen("/tmp/accumulatedfucks", "r+b");
  if (fp == NULL) {
    fp = fopen("/tmp/accumulatedfucks", "w+b");
  }
  get_fucks(fp, &fucks);
  switch (fucks) {
  case 0:
    printf("You shall be forgiven!\n");
    break;
  case 1:
    printf("Forgiving you for one lonely fuck.\n");
    break;
  default:
    printf("All the %d f-words are forgiven.\n", fucks);
  }
  fucks = 0;
  store_fucks(fp, &fucks);
  fclose(fp);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1198 <main+0x48>
lea    0xe78(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <get_fucks@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
test   %rax,%rax
je     11ce <main+0x7e>
jmp    11bb <main+0x6b>
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
je     11e1 <main+0x91>
jmp    11f4 <main+0xa4>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1206 <main+0xb6>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1206 <main+0xb6>
mov    -0x10(%rbp),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <store_fucks@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe94(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1196 <main+0x36>
lea    0xe79(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <get_fucks@plt>
mov    0x8(%rsp),%rsi
cmp    $0x1,%rsi
je     11c1 <main+0x61>
test   %rsi,%rsi
jne    11cf <main+0x6f>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
jmp    11dd <main+0x7d>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
jmp    11dd <main+0x7d>
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <store_fucks@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"/tmp/accumulatedfucks\00"
@.str.1 = [4 x i8] c"r+b\00"
@.str.2 = [4 x i8] c"w+b\00"
@.str.3 = [24 x i8] c"You shall be forgiven!\0A\00"
@.str.4 = [36 x i8] c"Forgiving you for one lonely fuck.\0A\00"
@.str.5 = [34 x i8] c"All the %d f-words are forgiven.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
%5 = load i32*, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32* %8, i32** %3
br label %9
9: ; preds = %7, %0
%10 = load i32*, i32** %3
%11 = call i32 @get_fucks(i32* %10, i64* %2)
%12 = load i64, i64* %2
switch i64 %12, label %17 [
i64 0, label %13
i64 1, label %15
]
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %20
15: ; preds = %9
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
br label %20
17: ; preds = %9
%18 = load i64, i64* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i64 %18)
br label %20
20: ; preds = %17, %15, %13
store i64 0, i64* %2
%21 = load i32*, i32** %3
%22 = call i32 @store_fucks(i32* %21, i64* %2)
%23 = load i32*, i32** %3
%24 = call i32 @fclose(i32* %23)
%25 = load i32, i32* @EXIT_SUCCESS
ret i32 %25
}

LLVM IR (-O2):
@.str = [22 x i8] c"/tmp/accumulatedfucks\00"
@.str.1 = [4 x i8] c"r+b\00"
@.str.2 = [4 x i8] c"w+b\00"
@.str.5 = [34 x i8] c"All the %d f-words are forgiven.\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [35 x i8] c"Forgiving you for one lonely fuck.\00"
@str.6 = [23 x i8] c"You shall be forgiven!\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = phi i32* [ %6, %5 ], [ %3, %0 ]
%9 = call i32 @get_fucks(i32* %8, i64* %1)
%10 = load i64, i64* %1
switch i64 %10, label %15 [
i64 0, label %11
i64 1, label %13
]
11: ; preds = %7
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
br label %17
13: ; preds = %7
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %17
15: ; preds = %7
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i64 %10)
br label %17
17: ; preds = %15, %13, %11
store i64 0, i64* %1
%18 = call i32 @store_fucks(i32* %8, i64* %1)
%19 = call i32 @fclose(i32* %8)
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}