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

/* Variables and functions */
int /*<<< orphan*/ buffer_d(char *);
int /*<<< orphan*/ buffer_e(char *);
int /*<<< orphan*/ buffer_f(char *);
int /*<<< orphan*/ buffer_h(char *);
int /*<<< orphan*/ buffer_l(char *);
int /*<<< orphan*/ buffer_u(char *);
int /*<<< orphan*/ do_hash(struct session *, char *);
int /*<<< orphan*/ do_writebuffer(struct session *, char *);
char *get_arg_in_braces(char *, char *, int);
struct session *do_buffer(struct session *ses, char *arg) {
  char left[10000], right[10000];
  arg = get_arg_in_braces(arg, left, 0);
  arg = get_arg_in_braces(arg, right, 1);
  switch (left[0]) {
  case 'h':
    buffer_h("");
    break;
  case 'u':
    buffer_u("");
    break;
  case 'd':
    buffer_d("");
    break;
  case 'e':
    buffer_e("");
    break;
  case 'f':
    buffer_f(right);
    break;
  case 'w':
    do_writebuffer(ses, right);
    break;
  case 'i':
    do_hash(ses, right);
    break;
  case 'l':
    buffer_l("");
    break;
  default:
    buffer_e("");
    break;
  }
  return ses;
}


x86 assembly (clang, -O0):
<do_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x2720(%rbp),%rsi
xor    %edx,%edx
call   1050 <get_arg_in_braces@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x4e30(%rbp),%rsi
mov    $0x1,%edx
call   1050 <get_arg_in_braces@plt>
mov    %rax,-0x10(%rbp)
movsbl -0x2720(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x4e38(%rbp)
sub    $0x13,%eax
ja     1295 <do_buffer+0x105>
mov    -0x4e38(%rbp),%rax
lea    0xe04(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe44(%rip),%rdi
call   10a0 <buffer_h@plt>
jmp    12a1 <do_buffer+0x111>
lea    0xe33(%rip),%rdi
call   1060 <buffer_u@plt>
jmp    12a1 <do_buffer+0x111>
lea    0xe22(%rip),%rdi
call   1090 <buffer_d@plt>
jmp    12a1 <do_buffer+0x111>
lea    0xe11(%rip),%rdi
call   1040 <buffer_e@plt>
jmp    12a1 <do_buffer+0x111>
lea    -0x4e30(%rbp),%rdi
call   1080 <buffer_f@plt>
jmp    12a1 <do_buffer+0x111>
mov    -0x8(%rbp),%rdi
lea    -0x4e30(%rbp),%rsi
call   10b0 <do_writebuffer@plt>
jmp    12a1 <do_buffer+0x111>
mov    -0x8(%rbp),%rdi
lea    -0x4e30(%rbp),%rsi
call   1070 <do_hash@plt>
jmp    12a1 <do_buffer+0x111>
lea    0xdc5(%rip),%rdi
call   1030 <buffer_l@plt>
jmp    12a1 <do_buffer+0x111>
lea    0xdb4(%rip),%rdi
call   1040 <buffer_e@plt>
mov    -0x8(%rbp),%rax
add    $0x4e40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_buffer>:
push   %rbx
sub    $0x4e20,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0x2710(%rsp),%rsi
mov    %rax,%rdi
xor    %edx,%edx
call   1050 <get_arg_in_braces@plt>
mov    %rsp,%rsi
mov    %rax,%rdi
mov    $0x1,%edx
call   1050 <get_arg_in_braces@plt>
movsbl 0x2710(%rsp),%eax
add    $0xffffff9c,%eax
cmp    $0x13,%eax
ja     11e0 <do_buffer+0x50>
lea    0xe29(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe69(%rip),%rdi
call   1040 <buffer_e@plt>
jmp    1248 <do_buffer+0xb8>
lea    0xe5b(%rip),%rdi
call   1090 <buffer_d@plt>
jmp    1248 <do_buffer+0xb8>
mov    %rsp,%rdi
call   1080 <buffer_f@plt>
jmp    1248 <do_buffer+0xb8>
lea    0xe43(%rip),%rdi
call   10a0 <buffer_h@plt>
jmp    1248 <do_buffer+0xb8>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1070 <do_hash@plt>
jmp    1248 <do_buffer+0xb8>
lea    0xe28(%rip),%rdi
call   1030 <buffer_l@plt>
jmp    1248 <do_buffer+0xb8>
lea    0xe1a(%rip),%rdi
call   1060 <buffer_u@plt>
jmp    1248 <do_buffer+0xb8>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   10b0 <do_writebuffer@plt>
mov    %rbx,%rax
add    $0x4e20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.session = type { i32 }
@.str = [1 x i8] zeroinitializer
define %struct.session* @do_buffer(%struct.session* %0, i8* %1) {
%3 = alloca %struct.session*
%4 = alloca i8*
%5 = alloca [10000 x i8]
%6 = alloca [10000 x i8]
store %struct.session* %0, %struct.session** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%9 = call i8* @get_arg_in_braces(i8* %7, i8* %8, i32 0)
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%12 = call i8* @get_arg_in_braces(i8* %10, i8* %11, i32 1)
store i8* %12, i8** %4
%13 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %37 [
i32 104, label %16
i32 117, label %18
i32 100, label %20
i32 101, label %22
i32 102, label %24
i32 119, label %27
i32 105, label %31
i32 108, label %35
]
16: ; preds = %2
%17 = call i32 @buffer_h(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %39
18: ; preds = %2
%19 = call i32 @buffer_u(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %39
20: ; preds = %2
%21 = call i32 @buffer_d(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %39
22: ; preds = %2
%23 = call i32 @buffer_e(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %39
24: ; preds = %2
%25 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%26 = call i32 @buffer_f(i8* %25)
br label %39
27: ; preds = %2
%28 = load %struct.session*, %struct.session** %3
%29 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%30 = call i32 @do_writebuffer(%struct.session* %28, i8* %29)
br label %39
31: ; preds = %2
%32 = load %struct.session*, %struct.session** %3
%33 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%34 = call i32 @do_hash(%struct.session* %32, i8* %33)
br label %39
35: ; preds = %2
%36 = call i32 @buffer_l(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %39
37: ; preds = %2
%38 = call i32 @buffer_e(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %39
39: ; preds = %37, %35, %31, %27, %24, %22, %20, %18, %16
%40 = load %struct.session*, %struct.session** %3
ret %struct.session* %40
}

LLVM IR (-O2):
%struct.session = type { i32 }
@.str = [1 x i8] zeroinitializer
define %struct.session* @do_buffer(%struct.session* returned %0, i8* %1) {
%3 = alloca [10000 x i8]
%4 = alloca [10000 x i8]
%5 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%7 = call i8* @get_arg_in_braces(i8* %1, i8* %5, i32 0)
%8 = call i8* @get_arg_in_braces(i8* %7, i8* %6, i32 1)
%9 = load i8, i8* %5
%10 = sext i8 %9 to i32
switch i32 %10, label %27 [
i32 104, label %11
i32 117, label %13
i32 100, label %15
i32 101, label %17
i32 102, label %19
i32 119, label %21
i32 105, label %23
i32 108, label %25
]
11: ; preds = %2
%12 = call i32 @buffer_h(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %29
13: ; preds = %2
%14 = call i32 @buffer_u(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %29
15: ; preds = %2
%16 = call i32 @buffer_d(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %29
17: ; preds = %2
%18 = call i32 @buffer_e(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %29
19: ; preds = %2
%20 = call i32 @buffer_f(i8* %6)
br label %29
21: ; preds = %2
%22 = call i32 @do_writebuffer(%struct.session* %0, i8* %6)
br label %29
23: ; preds = %2
%24 = call i32 @do_hash(%struct.session* %0, i8* %6)
br label %29
25: ; preds = %2
%26 = call i32 @buffer_l(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %29
27: ; preds = %2
%28 = call i32 @buffer_e(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %25, %23, %21, %19, %17, %15, %13, %11
ret %struct.session* %0
}