#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 *, char const *);
int /*<<< orphan*/ putchar(char);
int strlen(char const *);
void print_menu_item(const char *menu_text, int align, int new_line) {
  int text_len;
  int prefix_num, i;
  text_len = strlen(menu_text);
  prefix_num = (40 - text_len) / 2;
  if (align == 1) {
    for (i = 0; i < prefix_num; i++) {
      putchar(' ');
    }
  }
  printf("%s", menu_text);
  for (i = 0; i < prefix_num; i++) {
    putchar(' ');
  }
  if (new_line == 1) {
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<print_menu_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    $0x28,%eax
sub    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    119b <print_menu_item+0x6b>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1196 <print_menu_item+0x66>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1172 <print_menu_item+0x42>
jmp    119b <print_menu_item+0x6b>
mov    -0x8(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d6 <print_menu_item+0xa6>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b2 <print_menu_item+0x82>
cmpl   $0x1,-0x10(%rbp)
jne    11ea <print_menu_item+0xba>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_menu_item>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r12d
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%r13d
mov    $0x28,%eax
sub    %r13d,%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
cmp    $0x1,%r12d
jne    118f <print_menu_item+0x5f>
cmp    $0x26,%r13d
jg     118f <print_menu_item+0x5f>
cmp    $0x2,%ebx
mov    $0x1,%ebp
cmovge %ebx,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1180 <print_menu_item+0x50>
lea    0xe6a(%rip),%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
cmp    $0x26,%r13d
jg     11bf <print_menu_item+0x8f>
cmp    $0x2,%ebx
mov    $0x1,%ebp
cmovge %ebx,%ebp
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11b0 <print_menu_item+0x80>
cmp    $0x1,%r14d
jne    11dd <print_menu_item+0xad>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @print_menu_item(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = sub nsw i32 40, %12
%14 = sdiv i32 %13, 2
store i32 %14, i32* %8
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %28
17: ; preds = %3
store i32 0, i32* %9
br label %18
18: ; preds = %24, %17
%19 = load i32, i32* %9
%20 = load i32, i32* %8
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = call i32 @putchar(i8 signext 32)
br label %24
24: ; preds = %22
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %18
27: ; preds = %18
br label %28
28: ; preds = %27, %3
%29 = load i8*, i8** %4
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %29)
store i32 0, i32* %9
br label %31
31: ; preds = %37, %28
%32 = load i32, i32* %9
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = call i32 @putchar(i8 signext 32)
br label %37
37: ; preds = %35
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %31
40: ; preds = %31
%41 = load i32, i32* %6
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @putchar(i8 signext 10)
br label %45
45: ; preds = %43, %40
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @print_menu_item(i8* %0, i32 %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = sub nsw i32 40, %4
%6 = sdiv i32 %5, 2
%7 = icmp eq i32 %1, 1
%8 = icmp slt i32 %4, 39
%9 = select i1 %7, i1 %8, i1 false
br i1 %9, label %10, label %17
10: ; preds = %3
%11 = call i32 @llvm.smax.i32(i32 %6, i32 1)
br label %12
12: ; preds = %10, %12
%13 = phi i32 [ %15, %12 ], [ 0, %10 ]
%14 = tail call i32 @putchar(i8 signext 32)
%15 = add nuw nsw i32 %13, 1
%16 = icmp eq i32 %15, %11
br i1 %16, label %17, label %12
17: ; preds = %12, %3
%18 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br i1 %8, label %19, label %26
19: ; preds = %17
%20 = call i32 @llvm.smax.i32(i32 %6, i32 1)
br label %21
21: ; preds = %19, %21
%22 = phi i32 [ %24, %21 ], [ 0, %19 ]
%23 = tail call i32 @putchar(i8 signext 32)
%24 = add nuw nsw i32 %22, 1
%25 = icmp eq i32 %24, %20
br i1 %25, label %26, label %21
26: ; preds = %21, %17
%27 = icmp eq i32 %2, 1
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = tail call i32 @putchar(i8 signext 10)
br label %30
30: ; preds = %28, %26
ret void
}