#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*/ __start_kmc_server(char **);
int /*<<< orphan*/ __stop_kmc_server(int /*<<< orphan*/ *);
int check_kmod(char *);
int /*<<< orphan*/ insert_kmod(char *);
int /*<<< orphan*/ perror(char *);
void start_kmc_server(char *argv[]) {
  int status;
  status = check_kmod("kmemcache");
retry:
  switch (status) {
  case 0:
    insert_kmod(argv[0]);
    __start_kmc_server(argv + 1);
    break;
  case -1:
  default:
    perror("start_kmc_server");
    break;
  case 1:
    __stop_kmc_server(NULL);
    status = 0;
    goto retry;
  }
}


x86 assembly (clang, -O0):
<start_kmc_server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
call   1030 <check_kmod@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0xffffffff,%eax
je     11be <start_kmc_server+0x6e>
jmp    117f <start_kmc_server+0x2f>
mov    -0x10(%rbp),%eax
test   %eax,%eax
je     11a0 <start_kmc_server+0x50>
jmp    118f <start_kmc_server+0x3f>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     11d4 <start_kmc_server+0x84>
jmp    11c3 <start_kmc_server+0x73>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <insert_kmod@plt>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
call   1040 <__start_kmc_server@plt>
jmp    11e9 <start_kmc_server+0x99>
jmp    11c3 <start_kmc_server+0x73>
lea    0xe40(%rip),%rdi
call   1060 <perror@plt>
jmp    11e9 <start_kmc_server+0x99>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <__stop_kmc_server@plt>
movl   $0x0,-0xc(%rbp)
jmp    116b <start_kmc_server+0x1b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_kmc_server>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xea2(%rip),%rdi
call   1030 <check_kmod@plt>
mov    %eax,%ebx
cmp    $0x1,%ebx
jne    117e <start_kmc_server+0x2e>
nopw   0x0(%rax,%rax,1)
xor    %ebx,%ebx
xor    %edi,%edi
call   1070 <__stop_kmc_server@plt>
cmp    $0x1,%ebx
je     1170 <start_kmc_server+0x20>
test   %ebx,%ebx
jne    119d <start_kmc_server+0x4d>
mov    (%r14),%rdi
call   1050 <insert_kmod@plt>
add    $0x8,%r14
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <__start_kmc_server@plt>
lea    0xe66(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <perror@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"kmemcache\00"
@.str.1 = [17 x i8] c"start_kmc_server\00"
define void @start_kmc_server(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
store i8** %0, i8*** %2
%4 = call i32 @check_kmod(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* %3
br label %5
5: ; preds = %18, %1
%6 = load i32, i32* %3
switch i32 %6, label %16 [
i32 0, label %7
i32 -1, label %15
i32 1, label %18
]
7: ; preds = %5
%8 = load i8**, i8*** %2
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i32 @insert_kmod(i8* %10)
%12 = load i8**, i8*** %2
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = call i32 @__start_kmc_server(i8** %13)
br label %20
15: ; preds = %5
br label %16
16: ; preds = %5, %15
%17 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %20
18: ; preds = %5
%19 = call i32 @__stop_kmc_server(i32* null)
store i32 0, i32* %3
br label %5
20: ; preds = %16, %7
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"kmemcache\00"
@.str.1 = [17 x i8] c"start_kmc_server\00"
define void @start_kmc_server(i8** %0) {
%2 = tail call i32 @check_kmod(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %12, %1
%4 = phi i32 [ %2, %1 ], [ 0, %12 ]
switch i32 %4, label %10 [
i32 0, label %5
i32 1, label %12
]
5: ; preds = %3
%6 = load i8*, i8** %0
%7 = tail call i32 @insert_kmod(i8* %6)
%8 = getelementptr inbounds i8*, i8** %0, i64 1
%9 = tail call i32 @__start_kmc_server(i8** %8)
br label %14
10: ; preds = %3
%11 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %14
12: ; preds = %3
%13 = tail call i32 @__stop_kmc_server(i32* null)
br label %3
14: ; preds = %10, %5
ret void
}