#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 show(const int type, const char *argv[], const char *envp[]) {
  size_t i;
  switch (type) {
  case 0:
    printf("OPENVPN_PLUGIN_UP\n");
    break;
  case 1:
    printf("OPENVPN_PLUGIN_DOWN\n");
    break;
  case 2:
    printf("OPENVPN_PLUGIN_ROUTE_UP\n");
    break;
  case 3:
    printf("OPENVPN_PLUGIN_IPCHANGE\n");
    break;
  case 4:
    printf("OPENVPN_PLUGIN_TLS_VERIFY\n");
    break;
  case 5:
    printf("OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY\n");
    break;
  case 9:
    printf("OPENVPN_PLUGIN_CLIENT_CONNECT_V2\n");
    break;
  case 7:
    printf("OPENVPN_PLUGIN_CLIENT_DISCONNECT\n");
    break;
  case 8:
    printf("OPENVPN_PLUGIN_LEARN_ADDRESS\n");
    break;
  case 10:
    printf("OPENVPN_PLUGIN_TLS_FINAL\n");
    break;
  default:
    printf("OPENVPN_PLUGIN_?\n");
    break;
  }
  printf("ARGV\n");
  for (i = 0; argv[i] != NULL; ++i)
    printf("%d '%s'\n", (int)i, argv[i]);
  printf("ENVP\n");
  for (i = 0; envp[i] != NULL; ++i)
    printf("%d '%s'\n", (int)i, envp[i]);
}


x86 assembly (clang, -O0):
<show>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0xa,%rax
ja     1206 <show+0xf6>
mov    -0x28(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <show+0x104>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <show+0x104>
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <show+0x104>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <show+0x104>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <show+0x104>
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <show+0x104>
lea    0xf06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <show+0x104>
lea    0xf15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <show+0x104>
lea    0xf24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <show+0x104>
lea    0xf2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <show+0x104>
lea    0xf36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     126e <show+0x15e>
mov    -0x20(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xf05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    122a <show+0x11a>
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     12c8 <show+0x1b8>
mov    -0x20(%rbp),%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1284 <show+0x174>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
cmp    $0xa,%edi
ja     1146 <show+0x26>
movslq %edi,%rax
lea    0xff7(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    114d <show+0x2d>
lea    0xfd3(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
mov    (%r12),%rdx
test   %rdx,%rdx
je     118a <show+0x6a>
lea    0xe92(%rip),%r15
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%r12,%rbx,8),%rdx
add    $0x1,%rbx
test   %rdx,%rdx
jne    1170 <show+0x50>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%rdx
test   %rdx,%rdx
je     11ca <show+0xaa>
lea    0xe5b(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%r14,%rbx,8),%rdx
add    $0x1,%rbx
test   %rdx,%rdx
jne    11b0 <show+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"OPENVPN_PLUGIN_UP\0A\00"
@.str.1 = [21 x i8] c"OPENVPN_PLUGIN_DOWN\0A\00"
@.str.2 = [25 x i8] c"OPENVPN_PLUGIN_ROUTE_UP\0A\00"
@.str.3 = [25 x i8] c"OPENVPN_PLUGIN_IPCHANGE\0A\00"
@.str.4 = [27 x i8] c"OPENVPN_PLUGIN_TLS_VERIFY\0A\00"
@.str.5 = [38 x i8] c"OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY\0A\00"
@.str.6 = [34 x i8] c"OPENVPN_PLUGIN_CLIENT_CONNECT_V2\0A\00"
@.str.7 = [34 x i8] c"OPENVPN_PLUGIN_CLIENT_DISCONNECT\0A\00"
@.str.8 = [30 x i8] c"OPENVPN_PLUGIN_LEARN_ADDRESS\0A\00"
@.str.9 = [26 x i8] c"OPENVPN_PLUGIN_TLS_FINAL\0A\00"
@.str.10 = [18 x i8] c"OPENVPN_PLUGIN_?\0A\00"
@.str.11 = [6 x i8] c"ARGV\0A\00"
@.str.12 = [9 x i8] c"%d '%s'\0A\00"
@.str.13 = [6 x i8] c"ENVP\0A\00"
define void @show(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i64
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%8 = load i32, i32* %4
switch i32 %8, label %29 [
i32 0, label %9
i32 1, label %11
i32 2, label %13
i32 3, label %15
i32 4, label %17
i32 5, label %19
i32 9, label %21
i32 7, label %23
i32 8, label %25
i32 10, label %27
]
9: ; preds = %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %31
11: ; preds = %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %31
13: ; preds = %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %31
15: ; preds = %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %31
17: ; preds = %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %31
19: ; preds = %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
br label %31
21: ; preds = %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %31
23: ; preds = %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
br label %31
25: ; preds = %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %31
27: ; preds = %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
br label %31
29: ; preds = %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
br label %31
31: ; preds = %29, %27, %25, %23, %21, %19, %17, %15, %13, %11, %9
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
store i64 0, i64* %7
br label %33
33: ; preds = %47, %31
%34 = load i8**, i8*** %5
%35 = load i64, i64* %7
%36 = getelementptr inbounds i8*, i8** %34, i64 %35
%37 = load i8*, i8** %36
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %50
39: ; preds = %33
%40 = load i64, i64* %7
%41 = trunc i64 %40 to i32
%42 = load i8**, i8*** %5
%43 = load i64, i64* %7
%44 = getelementptr inbounds i8*, i8** %42, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %41, i8* %45)
br label %47
47: ; preds = %39
%48 = load i64, i64* %7
%49 = add i64 %48, 1
store i64 %49, i64* %7
br label %33
50: ; preds = %33
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
store i64 0, i64* %7
br label %52
52: ; preds = %66, %50
%53 = load i8**, i8*** %6
%54 = load i64, i64* %7
%55 = getelementptr inbounds i8*, i8** %53, i64 %54
%56 = load i8*, i8** %55
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %69
58: ; preds = %52
%59 = load i64, i64* %7
%60 = trunc i64 %59 to i32
%61 = load i8**, i8*** %6
%62 = load i64, i64* %7
%63 = getelementptr inbounds i8*, i8** %61, i64 %62
%64 = load i8*, i8** %63
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %60, i8* %64)
br label %66
66: ; preds = %58
%67 = load i64, i64* %7
%68 = add i64 %67, 1
store i64 %68, i64* %7
br label %52
69: ; preds = %52
ret void
}

LLVM IR (-O2):
@.str.12 = [9 x i8] c"%d '%s'\0A\00"
@str = [25 x i8] c"OPENVPN_PLUGIN_TLS_FINAL\00"
@str.14 = [5 x i8] c"ARGV\00"
@str.15 = [5 x i8] c"ENVP\00"
@str.16 = [29 x i8] c"OPENVPN_PLUGIN_LEARN_ADDRESS\00"
@str.17 = [33 x i8] c"OPENVPN_PLUGIN_CLIENT_DISCONNECT\00"
@str.18 = [33 x i8] c"OPENVPN_PLUGIN_CLIENT_CONNECT_V2\00"
@str.19 = [37 x i8] c"OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY\00"
@str.20 = [26 x i8] c"OPENVPN_PLUGIN_TLS_VERIFY\00"
@str.21 = [24 x i8] c"OPENVPN_PLUGIN_IPCHANGE\00"
@str.22 = [24 x i8] c"OPENVPN_PLUGIN_ROUTE_UP\00"
@str.23 = [20 x i8] c"OPENVPN_PLUGIN_DOWN\00"
@str.24 = [18 x i8] c"OPENVPN_PLUGIN_UP\00"
@str.25 = [17 x i8] c"OPENVPN_PLUGIN_?\00"
@reltable.show = [11 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @str.24 to i64), i64 ptrtoint ([11 x i32]* @reltable.show to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @str.23 to i64), i64 ptrtoint ([11 x i32]* @reltable.show to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @str.22 to i64), i64 ptrtoint ([11 x i32]* @reltable.show to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @str.21 to i64), i64 ptrtoint ([11 x i32]* @reltable.show to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @str.20 to i64), i64 ptrtoint ([11 x i32]* @reltable.show to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([37 x i8]* @str.19 to i64), i64 ptrtoint ([11 x i32]* @reltable.show to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str.25 to i64), i64 ptrtoint ([11 x i32]* @reltable.show to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([33 x i8]* @str.17 to i64), i64 ptrtoint ([11 x i32]* @reltable.show to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @str.16 to i64), i64 ptrtoint ([11 x i32]* @reltable.show to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([33 x i8]* @str.18 to i64), i64 ptrtoint ([11 x i32]* @reltable.show to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @str to i64), i64 ptrtoint ([11 x i32]* @reltable.show to i64)) to i32)]
define void @show(i32 %0, i8** nocapture %1, i8** nocapture %2) {
%4 = icmp ult i32 %0, 11
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = sext i32 %0 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([11 x i32]* @reltable.show to i8*), i64 %7)
br label %9
9: ; preds = %3, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.25, i64 0, i64 0), %3 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.14, i64 0, i64 0))
%13 = load i8*, i8** %1
%14 = icmp eq i8* %13, null
br i1 %14, label %24, label %15
15: ; preds = %9, %15
%16 = phi i8* [ %22, %15 ], [ %13, %9 ]
%17 = phi i64 [ %20, %15 ], [ 0, %9 ]
%18 = trunc i64 %17 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %18, i8* %16)
%20 = add i64 %17, 1
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %15
24: ; preds = %15, %9
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.15, i64 0, i64 0))
%26 = load i8*, i8** %2
%27 = icmp eq i8* %26, null
br i1 %27, label %37, label %28
28: ; preds = %24, %28
%29 = phi i8* [ %35, %28 ], [ %26, %24 ]
%30 = phi i64 [ %33, %28 ], [ 0, %24 ]
%31 = trunc i64 %30 to i32
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 %31, i8* %29)
%33 = add i64 %30, 1
%34 = getelementptr inbounds i8*, i8** %2, i64 %33
%35 = load i8*, i8** %34
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %28
37: ; preds = %28, %24
ret void
}