#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 rlimit {
  int member_0;
  int member_1;
};

/* Variables and functions */
int EXIT_FAILURE;
int /*<<< orphan*/ RLIMIT_CORE;
int /*<<< orphan*/ assert_test_func();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ panic_errno_test_func();
int /*<<< orphan*/ panic_test_func();
int /*<<< orphan*/ setrlimit(int /*<<< orphan*/, struct rlimit *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  struct rlimit rlim_unlimited = {-1, -1};
  struct rlimit rlim_zero = {0, 0};
  if (argc != 2)
    goto fail;
  if (strcmp(argv[1], "util_panic") == 0) {
    fprintf(stderr, "Disable core files: ulimit -c 0\n");
    setrlimit(RLIMIT_CORE, &rlim_zero);
    panic_test_func();
  } else if (strcmp(argv[1], "util_panic_errno") == 0) {
    setrlimit(RLIMIT_CORE, &rlim_unlimited);
    panic_errno_test_func();
  } else if (strcmp(argv[1], "util_assert") == 0) {
    fprintf(stderr, "Enable core files: ulimit -c unlimited\n");
    setrlimit(RLIMIT_CORE, &rlim_unlimited);
    assert_test_func();
  }
fail:
  fprintf(stderr, "Usage: %s util_panic|util_panic_errno|util_assert\n",
          argv[0]);
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe73(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
cmpl   $0x2,-0x8(%rbp)
je     11b0 <main+0x40>
jmp    129c <main+0x12c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe49(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <main+0x93>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1060 <setrlimit@plt>
mov    $0x0,%al
call   1070 <panic_test_func@plt>
jmp    1297 <main+0x127>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe22(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    123f <main+0xcf>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1060 <setrlimit@plt>
mov    $0x0,%al
call   1090 <panic_errno_test_func@plt>
jmp    1292 <main+0x122>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    128d <main+0x11d>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1060 <setrlimit@plt>
mov    $0x0,%al
call   1080 <assert_test_func@plt>
jmp    1292 <main+0x122>
jmp    1297 <main+0x127>
jmp    129c <main+0x12c>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movq   $0xffffffffffffffff,(%rsp)
ff
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jne    123d <main+0xdd>
mov    0x8(%rbx),%rdi
lea    0xe73(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11f2 <main+0x92>
mov    0x8(%rbx),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1225 <main+0xc5>
mov    0x8(%rbx),%rdi
lea    0xe86(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    123d <main+0xdd>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1050 <setrlimit@plt>
xor    %eax,%eax
call   1070 <assert_test_func@plt>
jmp    123d <main+0xdd>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xe09(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1050 <setrlimit@plt>
xor    %eax,%eax
call   1060 <panic_test_func@plt>
jmp    123d <main+0xdd>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1050 <setrlimit@plt>
xor    %eax,%eax
call   1080 <panic_errno_test_func@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe21(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@__const.main.rlim_unlimited = %struct.rlimit { i32 -1, i32 -1 }
@.str = [11 x i8] c"util_panic\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"Disable core files: ulimit -c 0\0A\00"
@RLIMIT_CORE = global i32 0
@.str.2 = [17 x i8] c"util_panic_errno\00"
@.str.3 = [12 x i8] c"util_assert\00"
@.str.4 = [40 x i8] c"Enable core files: ulimit -c unlimited\0A\00"
@.str.5 = [51 x i8] c"Usage: %s util_panic|util_panic_errno|util_assert\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.rlimit
%7 = alloca %struct.rlimit
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast %struct.rlimit* %6 to i8*
%9 = bitcast %struct.rlimit* %7 to i8*
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %2
br label %50
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @RLIMIT_CORE
%23 = call i32 @setrlimit(i32 %22, %struct.rlimit* %7)
%24 = call i32 (...) @panic_test_func()
br label %49
25: ; preds = %13
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %25
%32 = load i32, i32* @RLIMIT_CORE
%33 = call i32 @setrlimit(i32 %32, %struct.rlimit* %6)
%34 = call i32 (...) @panic_errno_test_func()
br label %48
35: ; preds = %25
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %35
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%44 = load i32, i32* @RLIMIT_CORE
%45 = call i32 @setrlimit(i32 %44, %struct.rlimit* %6)
%46 = call i32 (...) @assert_test_func()
br label %47
47: ; preds = %41, %35
br label %48
48: ; preds = %47, %31
br label %49
49: ; preds = %48, %19
br label %50
50: ; preds = %49, %12
%51 = load i32, i32* @stderr
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 0
%54 = load i8*, i8** %53
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = load i32, i32* @EXIT_FAILURE
ret i32 %56
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i32 }
@.str = [11 x i8] c"util_panic\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"Disable core files: ulimit -c 0\0A\00"
@RLIMIT_CORE = global i32 0
@.str.2 = [17 x i8] c"util_panic_errno\00"
@.str.3 = [12 x i8] c"util_assert\00"
@.str.4 = [40 x i8] c"Enable core files: ulimit -c unlimited\0A\00"
@.str.5 = [51 x i8] c"Usage: %s util_panic|util_panic_errno|util_assert\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to %struct.rlimit*
%5 = alloca i64
%6 = bitcast i64* %5 to %struct.rlimit*
%7 = bitcast i64* %3 to i8*
store i64 -1, i64* %3
%8 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%9 = icmp eq i32 %0, 2
br i1 %9, label %10, label %39
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @RLIMIT_CORE
%19 = call i32 @setrlimit(i32 %18, %struct.rlimit* %6)
%20 = call i32 (...) @panic_test_func()
br label %39
21: ; preds = %10
%22 = load i8*, i8** %11
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* @RLIMIT_CORE
%27 = call i32 @setrlimit(i32 %26, %struct.rlimit* %4)
%28 = call i32 (...) @panic_errno_test_func()
br label %39
29: ; preds = %21
%30 = load i8*, i8** %11
%31 = tail call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%36 = load i32, i32* @RLIMIT_CORE
%37 = call i32 @setrlimit(i32 %36, %struct.rlimit* %4)
%38 = call i32 (...) @assert_test_func()
br label %39
39: ; preds = %15, %29, %33, %25, %2
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %1
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i8* %41)
%43 = load i32, i32* @EXIT_FAILURE
ret i32 %43
}