#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 */
struct x509 {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int slurp(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ x509_insert(struct x509 *, int /*<<< orphan*/,
                               unsigned char *, int);
void readothercerts(struct x509 *othercerts, char *certfile) {
  char buf[65536];
  int l = slurp(certfile, buf, sizeof(buf));
  if (slurp(certfile, buf, sizeof(buf)) == 0)
    return;
  if (*buf != 0x30) {
    fprintf(stderr, "%s: not DER encoded certificates\n", certfile);
    exit(1);
  }
  x509_insert(othercerts, 0, (unsigned char *)buf, l);
}


x86 assembly (clang, -O0):
<readothercerts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10020,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x10010(%rbp),%rsi
mov    $0x10000,%edx
call   1030 <slurp@plt>
mov    %eax,-0x10014(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x10010(%rbp),%rsi
mov    $0x10000,%edx
call   1030 <slurp@plt>
cmp    $0x0,%eax
jne    1191 <readothercerts+0x51>
jmp    11dc <readothercerts+0x9c>
movsbl -0x10010(%rbp),%eax
cmp    $0x30,%eax
je     11c4 <readothercerts+0x84>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe4b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10010(%rbp),%rdx
mov    -0x10014(%rbp),%ecx
xor    %esi,%esi
call   1040 <x509_insert@plt>
add    $0x10020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readothercerts>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x10008,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%rbp
mov    %rsi,%rdi
mov    %rbp,%rsi
mov    $0x10000,%edx
call   1030 <slurp@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x10000,%edx
call   1030 <slurp@plt>
test   %eax,%eax
je     1193 <readothercerts+0x53>
cmpb   $0x30,(%rsp)
jne    11a1 <readothercerts+0x61>
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %esi,%esi
mov    %r15d,%ecx
call   1040 <x509_insert@plt>
add    $0x10008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.x509 = type { i32 }
@stderr = global i32 0
@.str = [34 x i8] c"%s: not DER encoded certificates\0A\00"
define void @readothercerts(%struct.x509* %0, i8* %1) {
%3 = alloca %struct.x509*
%4 = alloca i8*
%5 = alloca [65536 x i8]
%6 = alloca i32
store %struct.x509* %0, %struct.x509** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = getelementptr inbounds [65536 x i8], [65536 x i8]* %5, i64 0, i64 0
%9 = call i32 @slurp(i8* %7, i8* %8, i32 65536)
store i32 %9, i32* %6
%10 = load i8*, i8** %4
%11 = getelementptr inbounds [65536 x i8], [65536 x i8]* %5, i64 0, i64 0
%12 = call i32 @slurp(i8* %10, i8* %11, i32 65536)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %2
br label %30
15: ; preds = %2
%16 = getelementptr inbounds [65536 x i8], [65536 x i8]* %5, i64 0, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 48
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %4
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %15
%26 = load %struct.x509*, %struct.x509** %3
%27 = getelementptr inbounds [65536 x i8], [65536 x i8]* %5, i64 0, i64 0
%28 = load i32, i32* %6
%29 = call i32 @x509_insert(%struct.x509* %26, i32 0, i8* %27, i32 %28)
br label %30
30: ; preds = %25, %14
ret void
}

LLVM IR (-O2):
%struct.x509 = type { i32 }
@stderr = global i32 0
@.str = [34 x i8] c"%s: not DER encoded certificates\0A\00"
define void @readothercerts(%struct.x509* %0, i8* %1) {
%3 = alloca [65536 x i8]
%4 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
%5 = call i32 @slurp(i8* %1, i8* %4, i32 65536)
%6 = call i32 @slurp(i8* %1, i8* %4, i32 65536)
%7 = icmp eq i32 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %2
%9 = load i8, i8* %4
%10 = icmp eq i8 %9, 48
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %1)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %8
%16 = call i32 @x509_insert(%struct.x509* %0, i32 0, i8* %4, i32 %5)
br label %17
17: ; preds = %2, %15
ret void
}