#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 get_sym_alg_mode();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reset_sym_alg_mode();
int /*<<< orphan*/ skip(int);
extern void Symmetrically_Encrypted_and_MDC_Packet(int len) {
  int mode = get_sym_alg_mode();
  printf("\tVer %d\n", Getc());
  switch (mode) {
  case 2:
    printf("\tEncrypted data [sym alg is specified in sym-key encrypted "
           "session key]\n");
    break;
  case 3:
    printf("\tEncrypted data [sym alg is specified in pub-key encrypted "
           "session key]\n");
    break;
  }
  printf("\t\t(plain text + MDC SHA1(20 bytes))\n");
  skip(len - 1);
  reset_sym_alg_mode();
}


x86 assembly (clang, -O0):
<Symmetrically_Encrypted_and_MDC_Packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
mov    %al,-0xd(%rbp)
call   1040 <get_sym_alg_mode@plt>
mov    %eax,%ecx
mov    -0xd(%rbp),%al
mov    %ecx,-0x8(%rbp)
call   1070 <Getc@plt>
mov    %eax,%esi
mov    -0xd(%rbp),%al
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x2,%eax
je     11a8 <Symmetrically_Encrypted_and_MDC_Packet+0x58>
jmp    1197 <Symmetrically_Encrypted_and_MDC_Packet+0x47>
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
je     11bb <Symmetrically_Encrypted_and_MDC_Packet+0x6b>
jmp    11c9 <Symmetrically_Encrypted_and_MDC_Packet+0x79>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11c9 <Symmetrically_Encrypted_and_MDC_Packet+0x79>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
call   1030 <skip@plt>
mov    $0x0,%al
call   1060 <reset_sym_alg_mode@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Symmetrically_Encrypted_and_MDC_Packet>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <get_sym_alg_mode@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <Getc@plt>
lea    0xe84(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x2,%ebp
je     1198 <Symmetrically_Encrypted_and_MDC_Packet+0x38>
cmp    $0x3,%ebp
jne    11a4 <Symmetrically_Encrypted_and_MDC_Packet+0x44>
lea    0xe73(%rip),%rdi
jmp    119f <Symmetrically_Encrypted_and_MDC_Packet+0x3f>
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
add    $0xffffffff,%ebx
mov    %ebx,%edi
call   1030 <skip@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <reset_sym_alg_mode@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"\09Ver %d\0A\00"
@.str.1 = [73 x i8] c"\09Encrypted data [sym alg is specified in sym-key encrypted session key]\0A\00"
@.str.2 = [73 x i8] c"\09Encrypted data [sym alg is specified in pub-key encrypted session key]\0A\00"
@.str.3 = [37 x i8] c"\09\09(plain text + MDC SHA1(20 bytes))\0A\00"
define void @Symmetrically_Encrypted_and_MDC_Packet(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 (...) @get_sym_alg_mode()
store i32 %4, i32* %3
%5 = call i32 (...) @Getc()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %3
switch i32 %7, label %12 [
i32 2, label %8
i32 3, label %10
]
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.1, i64 0, i64 0))
br label %12
10: ; preds = %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %1, %10, %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = sub nsw i32 %14, 1
%16 = call i32 @skip(i32 %15)
%17 = call i32 (...) @reset_sym_alg_mode()
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"\09Ver %d\0A\00"
@str = [72 x i8] c"\09Encrypted data [sym alg is specified in pub-key encrypted session key]\00"
@str.4 = [36 x i8] c"\09\09(plain text + MDC SHA1(20 bytes))\00"
@str.5 = [72 x i8] c"\09Encrypted data [sym alg is specified in sym-key encrypted session key]\00"
define void @Symmetrically_Encrypted_and_MDC_Packet(i32 %0) {
%2 = tail call i32 (...) @get_sym_alg_mode()
%3 = tail call i32 (...) @Getc()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3)
switch i32 %2, label %9 [
i32 2, label %6
i32 3, label %5
]
5: ; preds = %1
br label %6
6: ; preds = %1, %5
%7 = phi i8* [ getelementptr inbounds ([72 x i8], [72 x i8]* @str, i64 0, i64 0), %5 ], [ getelementptr inbounds ([72 x i8], [72 x i8]* @str.5, i64 0, i64 0), %1 ]
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
br label %9
9: ; preds = %6, %1
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.4, i64 0, i64 0))
%11 = add nsw i32 %0, -1
%12 = tail call i32 @skip(i32 %11)
%13 = tail call i32 (...) @reset_sym_alg_mode()
ret void
}