#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*/ ASN1Print(char *, int, int /*<<< orphan*/,
                             int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void printASN1Structure(const unsigned int argc, char **argv) {
  unsigned int max = argc, argsCount = 1;
  char text_input[2000];
  strcpy(text_input, "");
  while (++argsCount < max) {
    if (argv[argsCount][0] == '-') {
      printf("[!] Unknown option to ASN.1 parser. %s option skipped\n",
             argv[argsCount]);
    } else {
      strncpy(text_input, argv[argsCount], 2000 - 1);
      break;
    }
  }
  if (text_input != NULL && strlen(text_input) > 1) {
    ASN1Print(text_input, 1, 0, 0);
  } else {
    printf(
        "[-] Comand line options NOT correct. ASN.1 text was NOT specified\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<printASN1Structure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
lea    -0x7f0(%rbp),%rdi
lea    0xeec(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmp    -0x14(%rbp),%eax
jae    11ff <printASN1Structure+0x9f>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11d9 <printASN1Structure+0x79>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    11fa <printASN1Structure+0x9a>
lea    -0x7f0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rsi
mov    $0x7cf,%edx
call   1030 <strncpy@plt>
jmp    11ff <printASN1Structure+0x9f>
jmp    1192 <printASN1Structure+0x32>
lea    -0x7f0(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x1,%eax
jle    122e <printASN1Structure+0xce>
lea    -0x7f0(%rbp),%rdi
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1070 <ASN1Print@plt>
jmp    1246 <printASN1Structure+0xe6>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printASN1Structure>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x7d8,%rsp
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xead(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcpy@plt>
cmp    $0x3,%ebp
jb     11db <printASN1Structure+0x6b>
mov    $0x2,%ebx
lea    0xe5e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%eax
mov    (%r15,%rax,8),%rsi
cmpb   $0x2d,(%rsi)
jne    11ce <printASN1Structure+0x5e>
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    11b0 <printASN1Structure+0x40>
jmp    11db <printASN1Structure+0x6b>
mov    %rsp,%rdi
mov    $0x7cf,%edx
call   1030 <strncpy@plt>
mov    %rsp,%rdi
call   1060 <strlen@plt>
cmp    $0x2,%eax
jl     1207 <printASN1Structure+0x97>
mov    %rsp,%rdi
mov    $0x1,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1080 <ASN1Print@plt>
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe29(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [55 x i8] c"[!] Unknown option to ASN.1 parser. %s option skipped\0A\00"
@.str.2 = [67 x i8] c"[-] Comand line options NOT correct. ASN.1 text was NOT specified\0A\00"
define void @printASN1Structure(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca [2000 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
store i32 %8, i32* %5
store i32 1, i32* %6
%9 = getelementptr inbounds [2000 x i8], [2000 x i8]* %7, i64 0, i64 0
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %41, %2
%12 = load i32, i32* %6
%13 = add i32 %12, 1
store i32 %13, i32* %6
%14 = load i32, i32* %5
%15 = icmp ult i32 %13, %14
br i1 %15, label %16, label %42
16: ; preds = %11
%17 = load i8**, i8*** %4
%18 = load i32, i32* %6
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 45
br i1 %25, label %26, label %33
26: ; preds = %16
%27 = load i8**, i8*** %4
%28 = load i32, i32* %6
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i8* %31)
br label %41
33: ; preds = %16
%34 = getelementptr inbounds [2000 x i8], [2000 x i8]* %7, i64 0, i64 0
%35 = load i8**, i8*** %4
%36 = load i32, i32* %6
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @strncpy(i8* %34, i8* %39, i32 1999)
br label %42
41: ; preds = %26
br label %11
42: ; preds = %33, %11
%43 = getelementptr inbounds [2000 x i8], [2000 x i8]* %7, i64 0, i64 0
%44 = call i32 @strlen(i8* %43)
%45 = icmp sgt i32 %44, 1
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = getelementptr inbounds [2000 x i8], [2000 x i8]* %7, i64 0, i64 0
%48 = call i32 @ASN1Print(i8* %47, i32 1, i32 0, i32 0)
br label %52
49: ; preds = %42
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %46
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [55 x i8] c"[!] Unknown option to ASN.1 parser. %s option skipped\0A\00"
@str = [66 x i8] c"[-] Comand line options NOT correct. ASN.1 text was NOT specified\00"
define void @printASN1Structure(i32 %0, i8** nocapture %1) {
%3 = alloca [2000 x i8]
%4 = getelementptr inbounds [2000 x i8], [2000 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%6 = icmp ugt i32 %0, 2
br i1 %6, label %7, label %20
7: ; preds = %2, %14
%8 = phi i32 [ %16, %14 ], [ 2, %2 ]
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 45
br i1 %13, label %14, label %18
14: ; preds = %7
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%16 = add i32 %8, 1
%17 = icmp eq i32 %16, %0
br i1 %17, label %20, label %7
18: ; preds = %7
%19 = call i32 @strncpy(i8* %4, i8* %11, i32 1999)
br label %20
20: ; preds = %14, %2, %18
%21 = call i32 @strlen(i8* %4)
%22 = icmp sgt i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @ASN1Print(i8* %4, i32 1, i32 0, i32 0)
ret void
25: ; preds = %20
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
}