#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 Getc();
int Getc_getlen();
int /*<<< orphan*/ Getc_resetlen();
int /*<<< orphan*/ IV(int /*<<< orphan*/);
int /*<<< orphan*/ Public_Key_Packet(int);
int /*<<< orphan*/ encrypted_Secret_Key(int, int);
int /*<<< orphan*/ iv_len(int);
int /*<<< orphan*/ plain_Secret_Key(int);
int /*<<< orphan*/ printf(char *);
int string_to_key();
int /*<<< orphan*/ sym_algs(int);
extern void Secret_Key_Packet(int len) {
  int s2k, sym;
  Getc_resetlen();
  Public_Key_Packet(len);
  s2k = Getc();
  switch (s2k) {
  case 0:
    plain_Secret_Key(len - Getc_getlen());
    break;
  case 254:
    sym = Getc();
    sym_algs(sym);
    if (string_to_key() == 1)
      IV(iv_len(sym));
    encrypted_Secret_Key(len - Getc_getlen(), 1);
    break;
  case 255:
    sym = Getc();
    sym_algs(sym);
    if (string_to_key() == 1)
      IV(iv_len(sym));
    encrypted_Secret_Key(len - Getc_getlen(), 0);
    break;
  default:
    sym = s2k;
    sym_algs(sym);
    printf("\tSimple string-to-key for IDEA\n");
    IV(iv_len(sym));
    encrypted_Secret_Key(len - Getc_getlen(), 0);
    break;
  }
}


x86 assembly (clang, -O0):
<Secret_Key_Packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
mov    %al,-0x11(%rbp)
call   10a0 <Getc_resetlen@plt>
mov    -0x4(%rbp),%edi
call   1090 <Public_Key_Packet@plt>
mov    -0x11(%rbp),%al
call   1070 <Getc@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1211 <Secret_Key_Packet+0x61>
jmp    11eb <Secret_Key_Packet+0x3b>
mov    -0x10(%rbp),%eax
sub    $0xfe,%eax
je     122d <Secret_Key_Packet+0x7d>
jmp    11fe <Secret_Key_Packet+0x4e>
mov    -0x10(%rbp),%eax
sub    $0xff,%eax
je     127f <Secret_Key_Packet+0xcf>
jmp    12ce <Secret_Key_Packet+0x11e>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   10b0 <Getc_getlen@plt>
mov    -0x18(%rbp),%edi
sub    %eax,%edi
call   1060 <plain_Secret_Key@plt>
jmp    1310 <Secret_Key_Packet+0x160>
mov    $0x0,%al
call   1070 <Getc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   10c0 <sym_algs@plt>
mov    $0x0,%al
call   1040 <string_to_key@plt>
cmp    $0x1,%eax
jne    125e <Secret_Key_Packet+0xae>
mov    -0xc(%rbp),%edi
call   1080 <iv_len@plt>
mov    %eax,%edi
call   10d0 <IV@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   10b0 <Getc_getlen@plt>
mov    -0x1c(%rbp),%edi
sub    %eax,%edi
mov    $0x1,%esi
call   1030 <encrypted_Secret_Key@plt>
jmp    1310 <Secret_Key_Packet+0x160>
mov    $0x0,%al
call   1070 <Getc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   10c0 <sym_algs@plt>
mov    $0x0,%al
call   1040 <string_to_key@plt>
cmp    $0x1,%eax
jne    12b0 <Secret_Key_Packet+0x100>
mov    -0xc(%rbp),%edi
call   1080 <iv_len@plt>
mov    %eax,%edi
call   10d0 <IV@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   10b0 <Getc_getlen@plt>
mov    -0x20(%rbp),%edi
sub    %eax,%edi
xor    %esi,%esi
call   1030 <encrypted_Secret_Key@plt>
jmp    1310 <Secret_Key_Packet+0x160>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   10c0 <sym_algs@plt>
lea    0xd1d(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
call   1080 <iv_len@plt>
mov    %eax,%edi
call   10d0 <IV@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   10b0 <Getc_getlen@plt>
mov    -0x24(%rbp),%edi
sub    %eax,%edi
xor    %esi,%esi
call   1030 <encrypted_Secret_Key@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Secret_Key_Packet>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   10a0 <Getc_resetlen@plt>
mov    %ebx,%edi
call   1090 <Public_Key_Packet@plt>
xor    %eax,%eax
call   1070 <Getc@plt>
cmp    $0xff,%eax
je     11f4 <Secret_Key_Packet+0x44>
mov    %eax,%ebp
cmp    $0xfe,%eax
je     1212 <Secret_Key_Packet+0x62>
test   %ebp,%ebp
jne    124e <Secret_Key_Packet+0x9e>
xor    %eax,%eax
call   10b0 <Getc_getlen@plt>
sub    %eax,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <plain_Secret_Key@plt>
xor    %eax,%eax
call   1070 <Getc@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   10c0 <sym_algs@plt>
xor    %eax,%eax
call   1040 <string_to_key@plt>
cmp    $0x1,%eax
je     1261 <Secret_Key_Packet+0xb1>
jmp    126f <Secret_Key_Packet+0xbf>
xor    %eax,%eax
call   1070 <Getc@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   10c0 <sym_algs@plt>
xor    %eax,%eax
call   1040 <string_to_key@plt>
cmp    $0x1,%eax
jne    123c <Secret_Key_Packet+0x8c>
mov    %ebp,%edi
call   1080 <iv_len@plt>
mov    %eax,%edi
call   10d0 <IV@plt>
xor    %eax,%eax
call   10b0 <Getc_getlen@plt>
sub    %eax,%ebx
mov    %ebx,%edi
mov    $0x1,%esi
jmp    127c <Secret_Key_Packet+0xcc>
mov    %ebp,%edi
call   10c0 <sym_algs@plt>
lea    0xda4(%rip),%rdi
call   1050 <puts@plt>
mov    %ebp,%edi
call   1080 <iv_len@plt>
mov    %eax,%edi
call   10d0 <IV@plt>
xor    %eax,%eax
call   10b0 <Getc_getlen@plt>
sub    %eax,%ebx
mov    %ebx,%edi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <encrypted_Secret_Key@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"\09Simple string-to-key for IDEA\0A\00"
define void @Secret_Key_Packet(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 (...) @Getc_resetlen()
%6 = load i32, i32* %2
%7 = call i32 @Public_Key_Packet(i32 %6)
%8 = call i32 (...) @Getc()
store i32 %8, i32* %3
%9 = load i32, i32* %3
switch i32 %9, label %45 [
i32 0, label %10
i32 254, label %15
i32 255, label %30
]
10: ; preds = %1
%11 = load i32, i32* %2
%12 = call i32 (...) @Getc_getlen()
%13 = sub nsw i32 %11, %12
%14 = call i32 @plain_Secret_Key(i32 %13)
br label %57
15: ; preds = %1
%16 = call i32 (...) @Getc()
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = call i32 @sym_algs(i32 %17)
%19 = call i32 (...) @string_to_key()
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = load i32, i32* %4
%23 = call i32 @iv_len(i32 %22)
%24 = call i32 @IV(i32 %23)
br label %25
25: ; preds = %21, %15
%26 = load i32, i32* %2
%27 = call i32 (...) @Getc_getlen()
%28 = sub nsw i32 %26, %27
%29 = call i32 @encrypted_Secret_Key(i32 %28, i32 1)
br label %57
30: ; preds = %1
%31 = call i32 (...) @Getc()
store i32 %31, i32* %4
%32 = load i32, i32* %4
%33 = call i32 @sym_algs(i32 %32)
%34 = call i32 (...) @string_to_key()
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %40
36: ; preds = %30
%37 = load i32, i32* %4
%38 = call i32 @iv_len(i32 %37)
%39 = call i32 @IV(i32 %38)
br label %40
40: ; preds = %36, %30
%41 = load i32, i32* %2
%42 = call i32 (...) @Getc_getlen()
%43 = sub nsw i32 %41, %42
%44 = call i32 @encrypted_Secret_Key(i32 %43, i32 0)
br label %57
45: ; preds = %1
%46 = load i32, i32* %3
store i32 %46, i32* %4
%47 = load i32, i32* %4
%48 = call i32 @sym_algs(i32 %47)
%49 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%50 = load i32, i32* %4
%51 = call i32 @iv_len(i32 %50)
%52 = call i32 @IV(i32 %51)
%53 = load i32, i32* %2
%54 = call i32 (...) @Getc_getlen()
%55 = sub nsw i32 %53, %54
%56 = call i32 @encrypted_Secret_Key(i32 %55, i32 0)
br label %57
57: ; preds = %45, %40, %25, %10
ret void
}

LLVM IR (-O2):
@str = [31 x i8] c"\09Simple string-to-key for IDEA\00"
define void @Secret_Key_Packet(i32 %0) {
%2 = tail call i32 (...) @Getc_resetlen()
%3 = tail call i32 @Public_Key_Packet(i32 %0)
%4 = tail call i32 (...) @Getc()
switch i32 %4, label %33 [
i32 0, label %5
i32 254, label %9
i32 255, label %21
]
5: ; preds = %1
%6 = tail call i32 (...) @Getc_getlen()
%7 = sub nsw i32 %0, %6
%8 = tail call i32 @plain_Secret_Key(i32 %7)
br label %41
9: ; preds = %1
%10 = tail call i32 (...) @Getc()
%11 = tail call i32 @sym_algs(i32 %10)
%12 = tail call i32 (...) @string_to_key()
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = tail call i32 @iv_len(i32 %10)
%16 = tail call i32 @IV(i32 %15)
br label %17
17: ; preds = %14, %9
%18 = tail call i32 (...) @Getc_getlen()
%19 = sub nsw i32 %0, %18
%20 = tail call i32 @encrypted_Secret_Key(i32 %19, i32 1)
br label %41
21: ; preds = %1
%22 = tail call i32 (...) @Getc()
%23 = tail call i32 @sym_algs(i32 %22)
%24 = tail call i32 (...) @string_to_key()
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = tail call i32 @iv_len(i32 %22)
%28 = tail call i32 @IV(i32 %27)
br label %29
29: ; preds = %26, %21
%30 = tail call i32 (...) @Getc_getlen()
%31 = sub nsw i32 %0, %30
%32 = tail call i32 @encrypted_Secret_Key(i32 %31, i32 0)
br label %41
33: ; preds = %1
%34 = tail call i32 @sym_algs(i32 %4)
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%36 = tail call i32 @iv_len(i32 %4)
%37 = tail call i32 @IV(i32 %36)
%38 = tail call i32 (...) @Getc_getlen()
%39 = sub nsw i32 %0, %38
%40 = tail call i32 @encrypted_Secret_Key(i32 %39, i32 0)
br label %41
41: ; preds = %33, %29, %17, %5
ret void
}