#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 XorrisO {
  int dummy;
};

/* Variables and functions */
int Xorriso_option_commit(struct XorrisO *, int);
int Xorriso_option_dev(struct XorrisO *, char *, int);
int Xorriso_option_eject(struct XorrisO *, char *, int);
scalar_t__ strcmp(char *, char *);
int Xorriso_option_commit_eject(struct XorrisO *xorriso, char *which,
                                int flag) {
  int ret, eret;
  ret = Xorriso_option_commit(xorriso, 1);
  if (ret <= 0 || ret == 2 || ret == 3)
    return (ret);
  if (strcmp(which, "none") == 0)
    eret = 1;
  else
    eret = Xorriso_option_eject(xorriso, which, 1);
  ret = Xorriso_option_dev(xorriso, "", 3 | 4);
  if (eret < ret)
    return (eret);
  return (ret);
}


x86 assembly (clang, -O0):
<Xorriso_option_commit_eject>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1060 <Xorriso_option_commit@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    1182 <Xorriso_option_commit_eject+0x42>
cmpl   $0x2,-0x20(%rbp)
je     1182 <Xorriso_option_commit_eject+0x42>
cmpl   $0x3,-0x20(%rbp)
jne    118d <Xorriso_option_commit_eject+0x4d>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fd <Xorriso_option_commit_eject+0xbd>
mov    -0x18(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b3 <Xorriso_option_commit_eject+0x73>
movl   $0x1,-0x24(%rbp)
jmp    11c8 <Xorriso_option_commit_eject+0x88>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   1040 <Xorriso_option_eject@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe31(%rip),%rsi
mov    $0x7,%edx
call   1050 <Xorriso_option_dev@plt>
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11f7 <Xorriso_option_commit_eject+0xb7>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fd <Xorriso_option_commit_eject+0xbd>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Xorriso_option_commit_eject>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%esi
call   1060 <Xorriso_option_commit@plt>
test   %eax,%eax
jle    11a8 <Xorriso_option_commit_eject+0x68>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
cmp    $0x2,%ecx
je     11a8 <Xorriso_option_commit_eject+0x68>
lea    0xe97(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     118a <Xorriso_option_commit_eject+0x4a>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <Xorriso_option_eject@plt>
mov    %eax,%ebp
jmp    118f <Xorriso_option_commit_eject+0x4f>
mov    $0x1,%ebp
lea    0xe6e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1050 <Xorriso_option_dev@plt>
cmp    %eax,%ebp
cmovl  %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.XorrisO = type { i32 }
@.str = [5 x i8] c"none\00"
@.str.1 = [1 x i8] zeroinitializer
define i32 @Xorriso_option_commit_eject(%struct.XorrisO* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.XorrisO*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store %struct.XorrisO* %0, %struct.XorrisO** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load %struct.XorrisO*, %struct.XorrisO** %5
%11 = call i32 @Xorriso_option_commit(%struct.XorrisO* %10, i32 1)
store i32 %11, i32* %8
%12 = load i32, i32* %8
%13 = icmp sle i32 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %3
%15 = load i32, i32* %8
%16 = icmp eq i32 %15, 2
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, 3
br i1 %19, label %20, label %22
20: ; preds = %17, %14, %3
%21 = load i32, i32* %8
store i32 %21, i32* %4
br label %41
22: ; preds = %17
%23 = load i8*, i8** %6
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 1, i32* %9
br label %31
27: ; preds = %22
%28 = load %struct.XorrisO*, %struct.XorrisO** %5
%29 = load i8*, i8** %6
%30 = call i32 @Xorriso_option_eject(%struct.XorrisO* %28, i8* %29, i32 1)
store i32 %30, i32* %9
br label %31
31: ; preds = %27, %26
%32 = load %struct.XorrisO*, %struct.XorrisO** %5
%33 = call i32 @Xorriso_option_dev(%struct.XorrisO* %32, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 7)
store i32 %33, i32* %8
%34 = load i32, i32* %9
%35 = load i32, i32* %8
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = load i32, i32* %9
store i32 %38, i32* %4
br label %41
39: ; preds = %31
%40 = load i32, i32* %8
store i32 %40, i32* %4
br label %41
41: ; preds = %39, %37, %20
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
%struct.XorrisO = type { i32 }
@.str = [5 x i8] c"none\00"
@.str.1 = [1 x i8] zeroinitializer
define i32 @Xorriso_option_commit_eject(%struct.XorrisO* %0, i8* %1, i32 %2) {
%4 = tail call i32 @Xorriso_option_commit(%struct.XorrisO* %0, i32 1)
%5 = icmp slt i32 %4, 1
%6 = and i32 %4, -2
%7 = icmp eq i32 %6, 2
%8 = or i1 %5, %7
br i1 %8, label %19, label %9
9: ; preds = %3
%10 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @Xorriso_option_eject(%struct.XorrisO* %0, i8* %1, i32 1)
br label %14
14: ; preds = %9, %12
%15 = phi i32 [ %13, %12 ], [ 1, %9 ]
%16 = tail call i32 @Xorriso_option_dev(%struct.XorrisO* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 7)
%17 = icmp slt i32 %15, %16
%18 = select i1 %17, i32 %15, i32 %16
br label %19
19: ; preds = %14, %3
%20 = phi i32 [ %4, %3 ], [ %18, %14 ]
ret i32 %20
}