#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 */
typedef int /*<<< orphan*/ choices;

/* Variables and functions */
int /*<<< orphan*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_BLUE;
int /*<<< orphan*/ COLOR_PAIR(int);
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ endwin();
int get_choice(char **, int, char *);
char *get_string(char *);
int /*<<< orphan*/ init_pair(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvprintw(int, int, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ wattron(int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  setlocale(LC_ALL, "");
  char *ca_name;
  char *choices[] = {"Create root CA",
                     "Create inwdsfsfsdfsdftermediate CA",
                     "123456789012345678901234567890",
                     "123456789012345678901234567890",
                     "123456789012345678901234567890",
                     "123456789012345678901234567890",
                     "123456789012345678901234567890",
                     "123456789012345678901234567890",
                     "123456789012345678901234567890",
                     "123456789012345678901234567890",
                     "123456789012345678901234567890",
                     "123456789012345678901234567890",
                     "123456789012345678901234567890",
                     "123456789012345678901234567890",
                     "Create intermediate CA",
                     "Crdsfsdfsdfsdfsdfsdfsdfsdfsdfsdfeate intermediate CA",
                     "Create certificate",
                     "Exit"};
  initscr();
  start_color();
  init_pair(2, COLOR_BLUE, COLOR_BLACK);
  wattron(stdscr, COLOR_PAIR(2));
  mvprintw(2, 10, "C - Graphic OpenSSL");
  int ch = get_choice(choices, (sizeof(choices) / sizeof(choices[0])),
                      "Select action");
  switch (ch) {
  case 1:
    ca_name = get_string("Enter CA name");
    break;
  case 2:
    ca_name = "ok";
    break;
  default:
    ca_name = "ok!";
    break;
  }
  endwin();
  printf("Selected: %d (%s)\n", ch, choices[ch - 1]);
  printf("CA name: %s\n", ca_name);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2def(%rip),%rax
mov    (%rax),%edi
lea    0xf1c(%rip),%rsi
call   10b0 <setlocale@plt>
lea    0x2b82(%rip),%rsi
lea    -0xa0(%rbp),%rdi
mov    %rdi,-0xb0(%rbp)
mov    $0x90,%edx
call   1080 <memcpy@plt>
xor    %eax,%eax
mov    %al,-0xb9(%rbp)
call   1060 <initscr@plt>
mov    -0xb9(%rbp),%al
call   1070 <start_color@plt>
mov    0x2dab(%rip),%rax
mov    (%rax),%esi
mov    0x2db2(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
mov    %edi,-0xb4(%rbp)
call   1030 <init_pair@plt>
mov    -0xb4(%rbp),%edi
mov    0x2d9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb8(%rbp)
call   1090 <COLOR_PAIR@plt>
mov    -0xb8(%rbp),%edi
mov    %eax,%esi
call   10d0 <wattron@plt>
mov    -0xb4(%rbp),%edi
lea    0xe41(%rip),%rdx
mov    $0xa,%esi
call   10e0 <mvprintw@plt>
mov    -0xb0(%rbp),%rdi
lea    0xe3d(%rip),%rdx
mov    $0x12,%esi
call   10a0 <get_choice@plt>
mov    %eax,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
mov    %eax,-0xa8(%rbp)
sub    $0x1,%eax
je     12ca <main+0x10a>
jmp    12b6 <main+0xf6>
mov    -0xa8(%rbp),%eax
sub    $0x2,%eax
je     12df <main+0x11f>
jmp    12ef <main+0x12f>
lea    0xe06(%rip),%rdi
call   1040 <get_string@plt>
mov    %rax,-0x10(%rbp)
jmp    12fa <main+0x13a>
lea    0xdff(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12fa <main+0x13a>
lea    0xdf2(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   10c0 <endwin@plt>
mov    -0xa4(%rbp),%esi
mov    -0xa4(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0xa0(%rbp,%rax,8),%rdx
ff
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xf23(%rip),%rsi
call   10b0 <setlocale@plt>
lea    0x2b89(%rip),%rsi
mov    %rsp,%rbx
mov    $0x90,%edx
mov    %rbx,%rdi
call   1080 <memcpy@plt>
xor    %eax,%eax
call   1060 <initscr@plt>
xor    %eax,%eax
call   1070 <start_color@plt>
mov    0x2dc4(%rip),%rax
mov    (%rax),%esi
mov    0x2dcb(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1030 <init_pair@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%ebp
mov    $0x2,%edi
call   1090 <COLOR_PAIR@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   10d0 <wattron@plt>
lea    0xe71(%rip),%rdx
mov    $0x2,%edi
mov    $0xa,%esi
call   10e0 <mvprintw@plt>
lea    0xe6f(%rip),%rdx
mov    %rbx,%rdi
mov    $0x12,%esi
call   10a0 <get_choice@plt>
mov    %eax,%ebx
cmp    $0x2,%eax
je     1284 <main+0xc4>
cmp    $0x1,%ebx
jne    128d <main+0xcd>
lea    0xe5d(%rip),%rdi
call   1040 <get_string@plt>
mov    %rax,%r14
jmp    1294 <main+0xd4>
lea    0xe5a(%rip),%r14
jmp    1294 <main+0xd4>
lea    0xe54(%rip),%r14
xor    %eax,%eax
call   10c0 <endwin@plt>
movslq %ebx,%rax
mov    -0x8(%rsp,%rax,8),%rdx
lea    0xe42(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe45(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [15 x i8] c"Create root CA\00"
@.str.2 = [35 x i8] c"Create inwdsfsfsdfsdftermediate CA\00"
@.str.3 = [31 x i8] c"123456789012345678901234567890\00"
@.str.4 = [23 x i8] c"Create intermediate CA\00"
@.str.5 = [53 x i8] c"Crdsfsdfsdfsdfsdfsdfsdfsdfsdfsdfeate intermediate CA\00"
@.str.6 = [19 x i8] c"Create certificate\00"
@.str.7 = [5 x i8] c"Exit\00"
@__const.main.choices = [18 x i8*] [i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0)]
@COLOR_BLUE = global i32 0
@COLOR_BLACK = global i32 0
@stdscr = global i32 0
@.str.8 = [20 x i8] c"C - Graphic OpenSSL\00"
@.str.9 = [14 x i8] c"Select action\00"
@.str.10 = [14 x i8] c"Enter CA name\00"
@.str.11 = [3 x i8] c"ok\00"
@.str.12 = [4 x i8] c"ok!\00"
@.str.13 = [19 x i8] c"Selected: %d (%s)\0A\00"
@.str.14 = [13 x i8] c"CA name: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [18 x i8*]
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* @LC_ALL
%6 = call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = bitcast [18 x i8*]* %3 to i8*
%8 = call i32 (...) @initscr()
%9 = call i32 (...) @start_color()
%10 = load i32, i32* @COLOR_BLUE
%11 = load i32, i32* @COLOR_BLACK
%12 = call i32 @init_pair(i32 2, i32 %10, i32 %11)
%13 = load i32, i32* @stdscr
%14 = call i32 @COLOR_PAIR(i32 2)
%15 = call i32 @wattron(i32 %13, i32 %14)
%16 = call i32 @mvprintw(i32 2, i32 10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%17 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 0
%18 = call i32 @get_choice(i8** %17, i32 18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
store i32 %18, i32* %4
%19 = load i32, i32* %4
switch i32 %19, label %23 [
i32 1, label %20
i32 2, label %22
]
20: ; preds = %0
%21 = call i8* @get_string(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
store i8* %21, i8** %2
br label %24
22: ; preds = %0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %24
23: ; preds = %0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %24
24: ; preds = %23, %22, %20
%25 = call i32 (...) @endwin()
%26 = load i32, i32* %4
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [18 x i8*], [18 x i8*]* %3, i64 0, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %26, i8* %31)
%33 = load i8*, i8** %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0), i8* %33)
ret i32 0
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [15 x i8] c"Create root CA\00"
@.str.2 = [35 x i8] c"Create inwdsfsfsdfsdftermediate CA\00"
@.str.3 = [31 x i8] c"123456789012345678901234567890\00"
@.str.4 = [23 x i8] c"Create intermediate CA\00"
@.str.5 = [53 x i8] c"Crdsfsdfsdfsdfsdfsdfsdfsdfsdfsdfeate intermediate CA\00"
@.str.6 = [19 x i8] c"Create certificate\00"
@.str.7 = [5 x i8] c"Exit\00"
@__const.main.choices = [18 x i8*] [i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0)]
@COLOR_BLUE = global i32 0
@COLOR_BLACK = global i32 0
@stdscr = global i32 0
@.str.8 = [20 x i8] c"C - Graphic OpenSSL\00"
@.str.9 = [14 x i8] c"Select action\00"
@.str.10 = [14 x i8] c"Enter CA name\00"
@.str.11 = [3 x i8] c"ok\00"
@.str.12 = [4 x i8] c"ok!\00"
@.str.13 = [19 x i8] c"Selected: %d (%s)\0A\00"
@.str.14 = [13 x i8] c"CA name: %s\0A\00"
define i32 @main() {
%1 = alloca [18 x i8*]
%2 = load i32, i32* @LC_ALL
%3 = tail call i32 @setlocale(i32 %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [18 x i8*]* %1 to i8*
%5 = tail call i32 (...) @initscr()
%6 = tail call i32 (...) @start_color()
%7 = load i32, i32* @COLOR_BLUE
%8 = load i32, i32* @COLOR_BLACK
%9 = tail call i32 @init_pair(i32 2, i32 %7, i32 %8)
%10 = load i32, i32* @stdscr
%11 = tail call i32 @COLOR_PAIR(i32 2)
%12 = tail call i32 @wattron(i32 %10, i32 %11)
%13 = tail call i32 @mvprintw(i32 2, i32 10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%14 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 0
%15 = call i32 @get_choice(i8** %14, i32 18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
switch i32 %15, label %18 [
i32 1, label %16
i32 2, label %19
]
16: ; preds = %0
%17 = call i8* @get_string(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
br label %19
18: ; preds = %0
br label %19
19: ; preds = %0, %18, %16
%20 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), %18 ], [ %17, %16 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), %0 ]
%21 = call i32 (...) @endwin()
%22 = add nsw i32 %15, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %15, i8* %25)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0), i8* %20)
ret i32 0
}