#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;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char);
void get_key_all(FILE *fp, int *key_off, int *key_name_off, int key_type) {
  int i, j;
  char c;
  for (i = 0; i < key_type; i++) {
    if (i == 1)
      continue;
    fseek(fp, key_off[i], SEEK_SET);
    for (j = 0; j < key_name_off[i + 1] - key_off[i]; j++) {
      c = fgetc(fp);
      printf("%c", c);
    }
  }
}


x86 assembly (clang, -O0):
<get_key_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f0 <get_key_all+0xc0>
cmpl   $0x1,-0x20(%rbp)
jne    1169 <get_key_all+0x39>
jmp    11e2 <get_key_all+0xb2>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    0x2e61(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
mov    (%rcx,%rdx,4),%ecx
mov    -0x10(%rbp),%rdx
movslq -0x20(%rbp),%rsi
sub    (%rdx,%rsi,4),%ecx
cmp    %ecx,%eax
jge    11dd <get_key_all+0xad>
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x25(%rbp)
lea    0xe3a(%rip),%rdi
movsbl -0x25(%rbp),%esi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118d <get_key_all+0x5d>
jmp    11e2 <get_key_all+0xb2>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114e <get_key_all+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_key_all>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %ecx,%ecx
jle    11e0 <get_key_all+0xb0>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %ecx,%r12d
xor    %ebp,%ebp
lea    0xea5(%rip),%r13
mov    %r12,0x8(%rsp)
jmp    1178 <get_key_all+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rcx,%rbp
cmp    %r12,%rcx
je     11e0 <get_key_all+0xb0>
mov    $0x2,%ecx
cmp    $0x1,%rbp
je     1170 <get_key_all+0x40>
mov    (%rbx,%rbp,4),%esi
mov    0x2e53(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
call   1050 <fseek@plt>
lea    0x1(%rbp),%rcx
mov    0x4(%r14,%rbp,4),%eax
cmp    (%rbx,%rbp,4),%eax
jle    1170 <get_key_all+0x40>
mov    %rcx,0x10(%rsp)
xor    %r12d,%r12d
nopl   (%rax)
mov    %r15,%rdi
call   1040 <fgetc@plt>
movsbl %al,%esi
mov    %r13,%rdi
call   1030 <printf@plt>
add    $0x1,%r12d
mov    0x4(%r14,%rbp,4),%eax
sub    (%rbx,%rbp,4),%eax
cmp    %eax,%r12d
jl     11b0 <get_key_all+0x80>
mov    0x8(%rsp),%r12
mov    0x10(%rsp),%rcx
jmp    1170 <get_key_all+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%c\00"
define void @get_key_all(i32* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %12
12: ; preds = %53, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %8
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %56
16: ; preds = %12
%17 = load i32, i32* %9
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %16
br label %53
20: ; preds = %16
%21 = load i32*, i32** %5
%22 = load i32*, i32** %6
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = load i32, i32* @SEEK_SET
%28 = call i32 @fseek(i32* %21, i32 %26, i32 %27)
store i32 0, i32* %10
br label %29
29: ; preds = %49, %20
%30 = load i32, i32* %10
%31 = load i32*, i32** %7
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %31, i64 %34
%36 = load i32, i32* %35
%37 = load i32*, i32** %6
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = sub nsw i32 %36, %41
%43 = icmp slt i32 %30, %42
br i1 %43, label %44, label %52
44: ; preds = %29
%45 = load i32*, i32** %5
%46 = call signext i8 @fgetc(i32* %45)
store i8 %46, i8* %11
%47 = load i8, i8* %11
%48 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %47)
br label %49
49: ; preds = %44
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
store i32 %51, i32* %10
br label %29
52: ; preds = %29
br label %53
53: ; preds = %52, %19
%54 = load i32, i32* %9
%55 = add nsw i32 %54, 1
store i32 %55, i32* %9
br label %12
56: ; preds = %12
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%c\00"
define void @get_key_all(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %33
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %6, %30
%9 = phi i64 [ 0, %6 ], [ %31, %30 ]
%10 = icmp eq i64 %9, 1
br i1 %10, label %30, label %11
11: ; preds = %8
%12 = getelementptr inbounds i32, i32* %1, i64 %9
%13 = load i32, i32* %12
%14 = load i32, i32* @SEEK_SET
%15 = tail call i32 @fseek(i32* %0, i32 %13, i32 %14)
%16 = add nuw nsw i64 %9, 1
%17 = getelementptr inbounds i32, i32* %2, i64 %16
%18 = load i32, i32* %17
%19 = load i32, i32* %12
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %11, %21
%22 = phi i32 [ %25, %21 ], [ 0, %11 ]
%23 = tail call signext i8 @fgetc(i32* %0)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %23)
%25 = add nuw nsw i32 %22, 1
%26 = load i32, i32* %17
%27 = load i32, i32* %12
%28 = sub nsw i32 %26, %27
%29 = icmp slt i32 %25, %28
br i1 %29, label %21, label %30
30: ; preds = %21, %8, %11
%31 = phi i64 [ %16, %11 ], [ 2, %8 ], [ %16, %21 ]
%32 = icmp eq i64 %31, %7
br i1 %32, label %33, label %8
33: ; preds = %30, %4
ret void
}