#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*/ SIGSEGV;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ raise(int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char const *, char *);
void libfunc(const char *action) {
  assert(action != NULL);
  if (strcmp(action, "segv") == 0)
    raise(SIGSEGV);
  if (strcmp(action, "sleep") == 0) {
    puts("sleeping");
    fflush(stdout);
    sleep(60);
  }
  assert(0);
}


x86 assembly (clang, -O0):
<libfunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a6 <libfunc+0x46>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
mov    -0x8(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e4 <libfunc+0x84>
lea    0xe44(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x3c,%edi
call   1080 <sleep@plt>
xor    %edi,%edi
call   1060 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libfunc>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1060 <assert@plt>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1194 <libfunc+0x34>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11cc <libfunc+0x6c>
lea    0xe5c(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x3c,%edi
call   1080 <sleep@plt>
xor    %edi,%edi
pop    %rbx
jmp    1060 <assert@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"segv\00"
@SIGSEGV = global i32 0
@.str.1 = [6 x i8] c"sleep\00"
@.str.2 = [9 x i8] c"sleeping\00"
@stdout = global i32 0
define void @libfunc(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = icmp ne i8* %3, null
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = load i8*, i8** %2
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* @SIGSEGV
%12 = call i32 @raise(i32 %11)
br label %13
13: ; preds = %10, %1
%14 = load i8*, i8** %2
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @stdout
%20 = call i32 @fflush(i32 %19)
%21 = call i32 @sleep(i32 60)
br label %22
22: ; preds = %17, %13
%23 = call i32 @assert(i32 0)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"segv\00"
@SIGSEGV = global i32 0
@.str.1 = [6 x i8] c"sleep\00"
@.str.2 = [9 x i8] c"sleeping\00"
@stdout = global i32 0
define void @libfunc(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @SIGSEGV
%9 = tail call i32 @raise(i32 %8)
br label %10
10: ; preds = %7, %1
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stdout
%16 = tail call i32 @fflush(i32 %15)
%17 = tail call i32 @sleep(i32 60)
br label %18
18: ; preds = %13, %10
%19 = tail call i32 @assert(i32 0)
ret void
}