#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 */
char *calloc(int, int);
int dsh_prompt_add_element(char **, char *, int);
char *dsh_prompt_interpret_shell_status(int status) {
  int buffsize = 2;
  char *prompt = NULL;
  if (status != 1) {
    prompt = calloc(buffsize, sizeof(char));
  }
  switch (status) {
  case 2:
    buffsize = dsh_prompt_add_element(&prompt, "killed", buffsize);
    break;
  default:
    break;
  }
  return prompt;
}


x86 assembly (clang, -O0):
<dsh_prompt_interpret_shell_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     1155 <dsh_prompt_interpret_shell_status+0x35>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x2,%eax
jne    1181 <dsh_prompt_interpret_shell_status+0x61>
jmp    1166 <dsh_prompt_interpret_shell_status+0x46>
mov    -0x8(%rbp),%edx
lea    -0x10(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1040 <dsh_prompt_add_element@plt>
mov    %eax,-0x8(%rbp)
jmp    1186 <dsh_prompt_interpret_shell_status+0x66>
jmp    1186 <dsh_prompt_interpret_shell_status+0x66>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsh_prompt_interpret_shell_status>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jne    112e <dsh_prompt_interpret_shell_status+0xe>
xor    %eax,%eax
jmp    1164 <dsh_prompt_interpret_shell_status+0x44>
mov    %edi,%ebx
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,0x8(%rsp)
cmp    $0x2,%ebx
jne    1164 <dsh_prompt_interpret_shell_status+0x44>
lea    0xeb0(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x2,%edx
call   1040 <dsh_prompt_add_element@plt>
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"killed\00"
define i8* @dsh_prompt_interpret_shell_status(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
store i32 2, i32* %3
store i8* null, i8** %4
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %3
%9 = call i8* @calloc(i32 %8, i32 1)
store i8* %9, i8** %4
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* %2
switch i32 %11, label %15 [
i32 2, label %12
]
12: ; preds = %10
%13 = load i32, i32* %3
%14 = call i32 @dsh_prompt_add_element(i8** %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 %14, i32* %3
br label %16
15: ; preds = %10
br label %16
16: ; preds = %15, %12
%17 = load i8*, i8** %4
ret i8* %17
}

LLVM IR (-O2):
@.str = [7 x i8] c"killed\00"
define i8* @dsh_prompt_interpret_shell_status(i32 %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = icmp eq i32 %0, 1
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = tail call dereferenceable_or_null(2) i8* @calloc(i32 2, i32 1)
store i8* %6, i8** %2
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = call i32 @dsh_prompt_add_element(i8** %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 2)
%10 = load i8*, i8** %2
br label %11
11: ; preds = %1, %5, %8
%12 = phi i8* [ null, %1 ], [ %6, %5 ], [ %10, %8 ]
ret i8* %12
}