#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*/ BUF_strlcat(char *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ PEM_BUFSIZE;
int PEM_TYPE_ENCRYPTED;
int PEM_TYPE_MIC_CLEAR;
int PEM_TYPE_MIC_ONLY;
void PEM_proc_type(char *buf, int type) {
  const char *str;
  if (type == PEM_TYPE_ENCRYPTED)
    str = "ENCRYPTED";
  else if (type == PEM_TYPE_MIC_CLEAR)
    str = "MIC-CLEAR";
  else if (type == PEM_TYPE_MIC_ONLY)
    str = "MIC-ONLY";
  else
    str = "BAD-TYPE";
  BUF_strlcat(buf, "Proc-Type: 4,", PEM_BUFSIZE);
  BUF_strlcat(buf, str, PEM_BUFSIZE);
  BUF_strlcat(buf, "\n", PEM_BUFSIZE);
}


x86 assembly (clang, -O0):
<PEM_proc_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2ea7(%rip),%rcx
cmp    (%rcx),%eax
jne    1141 <PEM_proc_type+0x31>
lea    0xec8(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    119a <PEM_proc_type+0x8a>
mov    -0xc(%rbp),%eax
mov    0x2e9d(%rip),%rcx
cmp    (%rcx),%eax
jne    1163 <PEM_proc_type+0x53>
lea    0xeb0(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1195 <PEM_proc_type+0x85>
mov    -0xc(%rbp),%eax
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%eax
jne    1185 <PEM_proc_type+0x75>
lea    0xe98(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1190 <PEM_proc_type+0x80>
lea    0xe91(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1195 <PEM_proc_type+0x85>
jmp    119a <PEM_proc_type+0x8a>
mov    -0x8(%rbp),%rdi
mov    0x2e23(%rip),%rax
mov    (%rax),%edx
lea    0xe78(%rip),%rsi
call   1030 <BUF_strlcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e06(%rip),%rax
mov    (%rax),%edx
call   1030 <BUF_strlcat@plt>
mov    -0x8(%rbp),%rdi
mov    0x2df4(%rip),%rax
mov    (%rax),%edx
lea    0xe57(%rip),%rsi
call   1030 <BUF_strlcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PEM_proc_type>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2eb1(%rip),%rax
cmp    %esi,(%rax)
jne    112c <PEM_proc_type+0x1c>
lea    0xed6(%rip),%r14
jmp    115b <PEM_proc_type+0x4b>
mov    0x2eb5(%rip),%rax
cmp    %esi,(%rax)
jne    1140 <PEM_proc_type+0x30>
lea    0xecc(%rip),%r14
jmp    115b <PEM_proc_type+0x4b>
mov    0x2e99(%rip),%rax
cmp    %esi,(%rax)
lea    0xec4(%rip),%rax
lea    0xec6(%rip),%r14
cmove  %rax,%r14
mov    0x2e66(%rip),%r15
mov    (%r15),%edx
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
call   1030 <BUF_strlcat@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <BUF_strlcat@plt>
mov    (%r15),%edx
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <BUF_strlcat@plt>

LLVM IR (-O0):
@PEM_TYPE_ENCRYPTED = global i32 0
@.str = [10 x i8] c"ENCRYPTED\00"
@PEM_TYPE_MIC_CLEAR = global i32 0
@.str.1 = [10 x i8] c"MIC-CLEAR\00"
@PEM_TYPE_MIC_ONLY = global i32 0
@.str.2 = [9 x i8] c"MIC-ONLY\00"
@.str.3 = [9 x i8] c"BAD-TYPE\00"
@.str.4 = [14 x i8] c"Proc-Type: 4,\00"
@PEM_BUFSIZE = global i32 0
@.str.5 = [2 x i8] c"\0A\00"
define void @PEM_proc_type(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = load i32, i32* @PEM_TYPE_ENCRYPTED
%8 = icmp eq i32 %6, %7
br i1 %8, label %9, label %10
9: ; preds = %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %5
br label %23
10: ; preds = %2
%11 = load i32, i32* %4
%12 = load i32, i32* @PEM_TYPE_MIC_CLEAR
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %15
14: ; preds = %10
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %22
15: ; preds = %10
%16 = load i32, i32* %4
%17 = load i32, i32* @PEM_TYPE_MIC_ONLY
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %15
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %5
br label %21
20: ; preds = %15
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %5
br label %21
21: ; preds = %20, %19
br label %22
22: ; preds = %21, %14
br label %23
23: ; preds = %22, %9
%24 = load i8*, i8** %3
%25 = load i32, i32* @PEM_BUFSIZE
%26 = call i32 @BUF_strlcat(i8* %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = load i8*, i8** %3
%28 = load i8*, i8** %5
%29 = load i32, i32* @PEM_BUFSIZE
%30 = call i32 @BUF_strlcat(i8* %27, i8* %28, i32 %29)
%31 = load i8*, i8** %3
%32 = load i32, i32* @PEM_BUFSIZE
%33 = call i32 @BUF_strlcat(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 %32)
ret void
}

LLVM IR (-O2):
@PEM_TYPE_ENCRYPTED = global i32 0
@.str = [10 x i8] c"ENCRYPTED\00"
@PEM_TYPE_MIC_CLEAR = global i32 0
@.str.1 = [10 x i8] c"MIC-CLEAR\00"
@PEM_TYPE_MIC_ONLY = global i32 0
@.str.2 = [9 x i8] c"MIC-ONLY\00"
@.str.3 = [9 x i8] c"BAD-TYPE\00"
@.str.4 = [14 x i8] c"Proc-Type: 4,\00"
@PEM_BUFSIZE = global i32 0
@.str.5 = [2 x i8] c"\0A\00"
define void @PEM_proc_type(i8* %0, i32 %1) {
%3 = load i32, i32* @PEM_TYPE_ENCRYPTED
%4 = icmp eq i32 %3, %1
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = load i32, i32* @PEM_TYPE_MIC_CLEAR
%7 = icmp eq i32 %6, %1
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = load i32, i32* @PEM_TYPE_MIC_ONLY
%10 = icmp eq i32 %9, %1
%11 = select i1 %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0)
br label %12
12: ; preds = %8, %5, %2
%13 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %5 ], [ %11, %8 ]
%14 = load i32, i32* @PEM_BUFSIZE
%15 = tail call i32 @BUF_strlcat(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @PEM_BUFSIZE
%17 = tail call i32 @BUF_strlcat(i8* %0, i8* %13, i32 %16)
%18 = load i32, i32* @PEM_BUFSIZE
%19 = tail call i32 @BUF_strlcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 %18)
ret void
}