#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*/ badassertion(char *, char *, int);
int t_safety(int rep, int count, int persistent, int safety) {
  if (safety == 3)
    safety = 2;
  switch (rep) {
  default:
    if (!(0))
      badassertion("x",
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/Godzil/ack/refs/heads/"
                   "to_ansi/util/LLgen/src/compute.c",
                   1127);
  case 03:
    if (!persistent || safety < 1)
      return 0;
    return 1;
  case 01:
    if (persistent)
      return 1;
    return 0;
  case 02:
    if (persistent) {
      if (safety > 1)
        return safety;
      return 1;
    }
    return safety;
  case 00:
    if (!count)
      return safety;
    return 2;
  }
}


x86 assembly (clang, -O0):
<t_safety>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jne    1135 <t_safety+0x25>
movl   $0x2,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x3,%rax
ja     115a <t_safety+0x4a>
mov    -0x20(%rbp),%rax
lea    0xeaf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeaf(%rip),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x467,%edx
call   1030 <badassertion@plt>
cmpl   $0x0,-0x10(%rbp)
je     1186 <t_safety+0x76>
cmpl   $0x1,-0x14(%rbp)
jge    1192 <t_safety+0x82>
movl   $0x0,-0x4(%rbp)
jmp    1212 <t_safety+0x102>
movl   $0x1,-0x4(%rbp)
jmp    1212 <t_safety+0x102>
cmpl   $0x0,-0x10(%rbp)
je     11b4 <t_safety+0xa4>
movl   $0x1,-0x4(%rbp)
jmp    1212 <t_safety+0x102>
movl   $0x0,-0x4(%rbp)
jmp    1212 <t_safety+0x102>
cmpl   $0x0,-0x10(%rbp)
je     11eb <t_safety+0xdb>
cmpl   $0x1,-0x14(%rbp)
jle    11df <t_safety+0xcf>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1212 <t_safety+0x102>
movl   $0x1,-0x4(%rbp)
jmp    1212 <t_safety+0x102>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1212 <t_safety+0x102>
cmpl   $0x0,-0xc(%rbp)
jne    120b <t_safety+0xfb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1212 <t_safety+0x102>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_safety>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
cmp    $0x3,%ecx
mov    $0x2,%ebx
cmovne %ecx,%ebx
cmp    $0x3,%edi
ja     1143 <t_safety+0x33>
mov    %edi,%eax
lea    0xed2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
test   %esi,%esi
mov    $0x2,%eax
cmovne %eax,%ebx
jmp    1183 <t_safety+0x73>
lea    0xec6(%rip),%rdi
lea    0xec1(%rip),%rsi
mov    $0x467,%edx
call   1030 <badassertion@plt>
test   %ebp,%ebp
setne  %al
test   %ebx,%ebx
setg   %cl
and    %al,%cl
movzbl %cl,%ebx
jmp    1183 <t_safety+0x73>
xor    %ebx,%ebx
test   %ebp,%ebp
setne  %bl
jmp    1183 <t_safety+0x73>
test   %ebp,%ebp
je     1183 <t_safety+0x73>
test   %ebx,%ebx
mov    $0x1,%eax
cmovle %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"x\00"
@.str.1 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Godzil/ack/refs/heads/to_ansi/util/LLgen/src/compute.c\00"
define i32 @t_safety(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 3
br i1 %11, label %12, label %13
12: ; preds = %4
store i32 2, i32* %9
br label %13
13: ; preds = %12, %4
%14 = load i32, i32* %6
switch i32 %14, label %15 [
i32 3, label %17
i32 1, label %25
i32 2, label %30
i32 0, label %41
]
15: ; preds = %13
%16 = call i32 @badassertion(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.1, i64 0, i64 0), i32 1127)
br label %17
17: ; preds = %13, %15
%18 = load i32, i32* %8
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %9
%22 = icmp slt i32 %21, 1
br i1 %22, label %23, label %24
23: ; preds = %20, %17
store i32 0, i32* %5
br label %47
24: ; preds = %20
store i32 1, i32* %5
br label %47
25: ; preds = %13
%26 = load i32, i32* %8
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 1, i32* %5
br label %47
29: ; preds = %25
store i32 0, i32* %5
br label %47
30: ; preds = %13
%31 = load i32, i32* %8
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %9
%35 = icmp sgt i32 %34, 1
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = load i32, i32* %9
store i32 %37, i32* %5
br label %47
38: ; preds = %33
store i32 1, i32* %5
br label %47
39: ; preds = %30
%40 = load i32, i32* %9
store i32 %40, i32* %5
br label %47
41: ; preds = %13
%42 = load i32, i32* %7
%43 = icmp ne i32 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %41
%45 = load i32, i32* %9
store i32 %45, i32* %5
br label %47
46: ; preds = %41
store i32 2, i32* %5
br label %47
47: ; preds = %46, %44, %39, %38, %36, %29, %28, %24, %23
%48 = load i32, i32* %5
ret i32 %48
}

LLVM IR (-O2):
@.str = [2 x i8] c"x\00"
@.str.1 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Godzil/ack/refs/heads/to_ansi/util/LLgen/src/compute.c\00"
define i32 @t_safety(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 3
%6 = select i1 %5, i32 2, i32 %3
switch i32 %0, label %7 [
i32 3, label %9
i32 1, label %14
i32 2, label %17
i32 0, label %22
]
7: ; preds = %4
%8 = tail call i32 @badassertion(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.1, i64 0, i64 0), i32 1127)
br label %9
9: ; preds = %4, %7
%10 = icmp ne i32 %2, 0
%11 = icmp sgt i32 %6, 0
%12 = and i1 %10, %11
%13 = zext i1 %12 to i32
br label %25
14: ; preds = %4
%15 = icmp ne i32 %2, 0
%16 = zext i1 %15 to i32
br label %25
17: ; preds = %4
%18 = icmp eq i32 %2, 0
br i1 %18, label %25, label %19
19: ; preds = %17
%20 = icmp sgt i32 %6, 1
%21 = select i1 %20, i32 %6, i32 1
br label %25
22: ; preds = %4
%23 = icmp eq i32 %1, 0
%24 = select i1 %23, i32 %6, i32 2
br label %25
25: ; preds = %22, %17, %19, %14, %9
%26 = phi i32 [ %13, %9 ], [ %16, %14 ], [ %21, %19 ], [ %6, %17 ], [ %24, %22 ]
ret i32 %26
}