#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
int str_to_int(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int get_RSA2048_E(FILE *fp, int *key_off, unsigned char *RSA2048_E) {
  int i;
  char c;
  char tmp_s[20];
  unsigned char E[4] = {0x00, 0x01, 0x00, 0x01};
  fseek(fp, key_off[1] + 1, SEEK_SET);
  fgets(tmp_s, 6, fp);
  printf("%s\n", tmp_s);
  if (!strcmp(tmp_s, "65537"))
    memcpy(RSA2048_E, E, 4);
  else {
    i = str_to_int(tmp_s);
  }
  for (i = 0; i < 4; i++)
    printf("%02x ", RSA2048_E[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<get_RSA2048_E>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xe86(%rip),%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
add    $0x1,%esi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x6,%esi
call   1050 <fgets@plt>
lea    -0x40(%rbp),%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11ed <get_RSA2048_E+0x8d>
mov    -0x18(%rbp),%rdi
lea    -0x44(%rbp),%rsi
mov    $0x4,%edx
call   1070 <memcpy@plt>
jmp    11f9 <get_RSA2048_E+0x99>
lea    -0x40(%rbp),%rdi
call   1030 <str_to_int@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1232 <get_RSA2048_E+0xd2>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1200 <get_RSA2048_E+0xa0>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_RSA2048_E>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
movl   $0x1000100,0xc(%rsp)
01
mov    0x4(%rsi),%esi
add    $0x1,%esi
mov    0x2e4c(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x6,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    $0x33353536,%eax
xor    0x10(%rsp),%eax
movzwl 0x14(%rsp),%ecx
xor    $0x37,%ecx
or     %eax,%ecx
je     11d9 <get_RSA2048_E+0x69>
lea    0x10(%rsp),%rdi
call   1050 <str_to_int@plt>
jmp    11eb <get_RSA2048_E+0x7b>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1080 <memcpy@plt>
movzbl (%r14),%esi
lea    0xe10(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x1(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x2(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x3(%r14),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.get_RSA2048_E.E = [4 x i8] c"\00\01\00\01"
@SEEK_SET = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [6 x i8] c"65537\00"
@.str.2 = [6 x i8] c"%02x \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @get_RSA2048_E(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8
%9 = alloca [20 x i8]
%10 = alloca [4 x i8]
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%11 = bitcast [4 x i8]* %10 to i8*
%12 = load i32*, i32** %4
%13 = load i32*, i32** %5
%14 = getelementptr inbounds i32, i32* %13, i64 1
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 1
%17 = load i32, i32* @SEEK_SET
%18 = call i32 @fseek(i32* %12, i32 %16, i32 %17)
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%20 = load i32*, i32** %4
%21 = call i32 @fgets(i8* %19, i32 6, i32* %20)
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %3
%28 = load i8*, i8** %6
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%30 = call i32 @memcpy(i8* %28, i8* %29, i32 4)
br label %34
31: ; preds = %3
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%33 = call i32 @str_to_int(i8* %32)
store i32 %33, i32* %7
br label %34
34: ; preds = %31, %27
store i32 0, i32* %7
br label %35
35: ; preds = %46, %34
%36 = load i32, i32* %7
%37 = icmp slt i32 %36, 4
br i1 %37, label %38, label %49
38: ; preds = %35
%39 = load i8*, i8** %6
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %38
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %35
49: ; preds = %35
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str.1 = [6 x i8] c"65537\00"
@.str.2 = [6 x i8] c"%02x \00"
define i32 @get_RSA2048_E(i32* nocapture %0, i32* nocapture %1, i8* %2) {
%4 = alloca [20 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%7 = bitcast i32* %5 to i8*
store i32 16777472, i32* %5
%8 = getelementptr inbounds i32, i32* %1, i64 1
%9 = load i32, i32* %8
%10 = add nsw i32 %9, 1
%11 = load i32, i32* @SEEK_SET
%12 = tail call i32 @fseek(i32* %0, i32 %10, i32 %11)
%13 = call i32 @fgets(i8* %6, i32 6, i32* %0)
%14 = call i32 @puts(i8* %6)
%15 = call i32 @bcmp(i8* dereferenceable(6) %6, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 6)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = call i32 @memcpy(i8* %2, i8* %7, i32 4)
br label %21
19: ; preds = %3
%20 = call i32 @str_to_int(i8* %6)
br label %21
21: ; preds = %19, %17
%22 = load i8, i8* %2
%23 = zext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds i8, i8* %2, i64 1
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds i8, i8* %2, i64 2
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds i8, i8* %2, i64 3
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = call i32 @putchar(i32 10)
ret i32 0
}