#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*/ primary_session_down();
int /*<<< orphan*/ primary_session_up();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ start_primary_session();
int /*<<< orphan*/ stop_primary_session();
scalar_t__ strcmp(char *, char *);
int primary_session(char *cmd) {
  if (strcmp(cmd, "restart") == 0) {
    stop_primary_session();
    sleep(2);
    start_primary_session();
  } else if (strcmp(cmd, "start") == 0)
    start_primary_session();
  else if (strcmp(cmd, "stop") == 0)
    stop_primary_session();
  else if (strcmp(cmd, "up") == 0)
    primary_session_up();
  else if (strcmp(cmd, "down") == 0)
    primary_session_down();
  return 0;
}


x86 assembly (clang, -O0):
<primary_session>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a3 <primary_session+0x43>
mov    $0x0,%al
call   1060 <stop_primary_session@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
mov    $0x0,%al
call   1040 <start_primary_session@plt>
jmp    124a <primary_session+0xea>
mov    -0x8(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c9 <primary_session+0x69>
mov    $0x0,%al
call   1040 <start_primary_session@plt>
jmp    1245 <primary_session+0xe5>
mov    -0x8(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11ef <primary_session+0x8f>
mov    $0x0,%al
call   1060 <stop_primary_session@plt>
jmp    1240 <primary_session+0xe0>
mov    -0x8(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1215 <primary_session+0xb5>
mov    $0x0,%al
call   1030 <primary_session_up@plt>
jmp    123b <primary_session+0xdb>
mov    -0x8(%rbp),%rdi
lea    0xdf0(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1236 <primary_session+0xd6>
mov    $0x0,%al
call   1070 <primary_session_down@plt>
jmp    123b <primary_session+0xdb>
jmp    1240 <primary_session+0xe0>
jmp    1245 <primary_session+0xe5>
jmp    124a <primary_session+0xea>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primary_session>:
push   %rbx
mov    %rdi,%rbx
lea    0xe95(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ce <primary_session+0x6e>
lea    0xe86(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11df <primary_session+0x7f>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ea <primary_session+0x8a>
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11f3 <primary_session+0x93>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11e6 <primary_session+0x86>
xor    %eax,%eax
call   1070 <primary_session_down@plt>
jmp    11e6 <primary_session+0x86>
xor    %eax,%eax
call   1060 <stop_primary_session@plt>
mov    $0x2,%edi
call   1080 <sleep@plt>
xor    %eax,%eax
call   1040 <start_primary_session@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1060 <stop_primary_session@plt>
jmp    11e6 <primary_session+0x86>
xor    %eax,%eax
call   1030 <primary_session_up@plt>
jmp    11e6 <primary_session+0x86>

LLVM IR (-O0):
@.str = [8 x i8] c"restart\00"
@.str.1 = [6 x i8] c"start\00"
@.str.2 = [5 x i8] c"stop\00"
@.str.3 = [3 x i8] c"up\00"
@.str.4 = [5 x i8] c"down\00"
define i32 @primary_session(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = call i32 (...) @stop_primary_session()
%8 = call i32 @sleep(i32 2)
%9 = call i32 (...) @start_primary_session()
br label %38
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 (...) @start_primary_session()
br label %37
16: ; preds = %10
%17 = load i8*, i8** %2
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (...) @stop_primary_session()
br label %36
22: ; preds = %16
%23 = load i8*, i8** %2
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (...) @primary_session_up()
br label %35
28: ; preds = %22
%29 = load i8*, i8** %2
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 (...) @primary_session_down()
br label %34
34: ; preds = %32, %28
br label %35
35: ; preds = %34, %26
br label %36
36: ; preds = %35, %20
br label %37
37: ; preds = %36, %14
br label %38
38: ; preds = %37, %6
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"restart\00"
@.str.1 = [6 x i8] c"start\00"
@.str.2 = [5 x i8] c"stop\00"
@.str.3 = [3 x i8] c"up\00"
@.str.4 = [5 x i8] c"down\00"
define i32 @primary_session(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i32 (...) @stop_primary_session()
%6 = tail call i32 @sleep(i32 2)
%7 = tail call i32 (...) @start_primary_session()
br label %28
8: ; preds = %1
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 (...) @start_primary_session()
br label %28
13: ; preds = %8
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 (...) @stop_primary_session()
br label %28
18: ; preds = %13
%19 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 (...) @primary_session_up()
br label %28
23: ; preds = %18
%24 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 (...) @primary_session_down()
br label %28
28: ; preds = %11, %21, %26, %23, %16, %4
ret i32 0
}