#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*/ printf(char *, ...);
void showmenu(const char *name, const char *x[]) {
  int ct, half, i;
  printf("\n");
  printf("%s\n", name);
  for (i = ct = 0; x[i]; i++) {
    ct++;
  }
  half = (ct + 1) / 2;
  for (i = 0; i < half; i++) {
    printf("    %-36s", x[i]);
    if (i + half < ct) {
      printf("%s", x[i + half]);
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<showmenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1178 <showmenu+0x68>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114e <showmenu+0x3e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1200 <showmenu+0xf0>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e4 <showmenu+0xd4>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1190 <showmenu+0x80>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showmenu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    (%r12),%rsi
test   %rsi,%rsi
je     11ee <showmenu+0xbe>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpq   $0x0,0x8(%r12,%rax,8)
lea    0x1(%rax),%rax
jne    1170 <showmenu+0x40>
test   %eax,%eax
je     11ee <showmenu+0xbe>
lea    0x1(%rax),%rcx
mov    %ecx,%ebx
shr    %rbx
shr    %ecx
cmp    $0x2,%ecx
mov    $0x1,%r13d
cmovae %ecx,%r13d
mov    %eax,%ebp
mov    $0x1,%r15d
lea    0xe59(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %rbp,%rbx
jae    11d1 <showmenu+0xa1>
mov    (%r12,%rbx,8),%rsi
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r15,%r13
je     11ee <showmenu+0xbe>
mov    (%r12,%r15,8),%rsi
add    $0x1,%rbx
add    $0x1,%r15
jmp    11b0 <showmenu+0x80>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [10 x i8] c" %-36s\00"
@.str.3 = [3 x i8] c"%s\00"
define void @showmenu(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8** %1, i8*** %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
store i32 0, i32* %5
store i32 0, i32* %7
br label %11
11: ; preds = %21, %2
%12 = load i8**, i8*** %4
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %24
18: ; preds = %11
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %21
21: ; preds = %18
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %11
24: ; preds = %11
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
%27 = sdiv i32 %26, 2
store i32 %27, i32* %6
store i32 0, i32* %7
br label %28
28: ; preds = %55, %24
%29 = load i32, i32* %7
%30 = load i32, i32* %6
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %58
32: ; preds = %28
%33 = load i8**, i8*** %4
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = load i32, i32* %7
%40 = load i32, i32* %6
%41 = add nsw i32 %39, %40
%42 = load i32, i32* %5
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %53
44: ; preds = %32
%45 = load i8**, i8*** %4
%46 = load i32, i32* %7
%47 = load i32, i32* %6
%48 = add nsw i32 %46, %47
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %45, i64 %49
%51 = load i8*, i8** %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %44, %32
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %55
55: ; preds = %53
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %28
58: ; preds = %28
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [10 x i8] c" %-36s\00"
@.str.3 = [3 x i8] c"%s\00"
define void @showmenu(i8* nocapture %0, i8** nocapture %1) {
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 @puts(i8* dereferenceable(1) %0)
%5 = load i8*, i8** %1
%6 = icmp eq i8* %5, null
br i1 %6, label %40, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %9, %7 ], [ 0, %2 ]
%9 = add nuw nsw i64 %8, 1
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %7
13: ; preds = %7
%14 = trunc i64 %9 to i32
%15 = add nuw nsw i32 %14, 1
%16 = lshr i32 %15, 1
%17 = icmp eq i32 %14, 0
br i1 %17, label %40, label %18
18: ; preds = %13
%19 = zext i32 %16 to i64
%20 = and i64 %9, 4294967295
%21 = call i32 @llvm.umax.i32(i32 %16, i32 1)
%22 = zext i32 %21 to i64
br label %23
23: ; preds = %37, %18
%24 = phi i8* [ %5, %18 ], [ %39, %37 ]
%25 = phi i64 [ 0, %18 ], [ %35, %37 ]
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%27 = add nuw nsw i64 %25, %19
%28 = icmp ult i64 %27, %20
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = getelementptr inbounds i8*, i8** %1, i64 %27
%31 = load i8*, i8** %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %29, %23
%34 = tail call i32 @putchar(i32 10)
%35 = add nuw nsw i64 %25, 1
%36 = icmp eq i64 %35, %22
br i1 %36, label %40, label %37
37: ; preds = %33
%38 = getelementptr inbounds i8*, i8** %1, i64 %35
%39 = load i8*, i8** %38
br label %23
40: ; preds = %33, %2, %13
%41 = tail call i32 @putchar(i32 10)
ret void
}