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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
void print_license(int license_part) {
  int start, end, line;
  FILE *fp;
  char buffer[0x100];
  switch (license_part) {
  case 0:
    start = 592;
    end = 624;
    break;
  case 1:
    start = 70;
    end = 625;
    break;
  default:
    return;
  }
  fp = fopen("LICENSE.txt", "r");
  if (fp == NULL) {
    perror("print_license: fopen");
    exit(EXIT_FAILURE);
  }
  for (line = 0; line < start; line++)
    fgets(buffer, sizeof(buffer), fp);
  for (; line < end; line++) {
    fgets(buffer, sizeof(buffer), fp);
    printf("%s", buffer);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<print_license>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x124(%rbp)
test   %eax,%eax
je     1198 <print_license+0x38>
jmp    1184 <print_license+0x24>
mov    -0x124(%rbp),%eax
sub    $0x1,%eax
je     11ab <print_license+0x4b>
jmp    11be <print_license+0x5e>
movl   $0x250,-0x8(%rbp)
movl   $0x270,-0xc(%rbp)
jmp    11c3 <print_license+0x63>
movl   $0x46,-0x8(%rbp)
movl   $0x271,-0xc(%rbp)
jmp    11c3 <print_license+0x63>
jmp    1285 <print_license+0x125>
lea    0xe36(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ff <print_license+0x9f>
lea    0xe22(%rip),%rdi
call   1070 <perror@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1235 <print_license+0xd5>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1206 <print_license+0xa6>
jmp    123a <print_license+0xda>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    127c <print_license+0x11c>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
lea    -0x120(%rbp),%rsi
lea    0xdba(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    123a <print_license+0xda>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_license>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
test   %edi,%edi
je     1189 <print_license+0x29>
cmp    $0x1,%edi
jne    1218 <print_license+0xb8>
mov    $0x46,%r15d
mov    $0x271,%ebp
jmp    1194 <print_license+0x34>
mov    $0x250,%r15d
mov    $0x270,%ebp
lea    0xe65(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1228 <print_license+0xc8>
mov    %rax,%r12
mov    %rsp,%r14
mov    %r15d,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
add    $0xffffffff,%ebx
jne    11c0 <print_license+0x60>
sub    %r15d,%ebp
mov    %rsp,%r14
lea    0xe41(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    11f0 <print_license+0x90>
mov    %r12,%rdi
call   1030 <fclose@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xddf(%rip),%rdi
call   1070 <perror@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"LICENSE.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"print_license: fopen\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define void @print_license(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca [256 x i8]
store i32 %0, i32* %2
%8 = load i32, i32* %2
switch i32 %8, label %11 [
i32 0, label %9
i32 1, label %10
]
9: ; preds = %1
store i32 592, i32* %3
store i32 624, i32* %4
br label %12
10: ; preds = %1
store i32 70, i32* %3
store i32 625, i32* %4
br label %12
11: ; preds = %1
br label %49
12: ; preds = %10, %9
%13 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %12
store i32 0, i32* %5
br label %21
21: ; preds = %29, %20
%22 = load i32, i32* %5
%23 = load i32, i32* %3
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%27 = load i32*, i32** %6
%28 = call i32 @fgets(i8* %26, i32 256, i32* %27)
br label %29
29: ; preds = %25
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %21
32: ; preds = %21
br label %33
33: ; preds = %43, %32
%34 = load i32, i32* %5
%35 = load i32, i32* %4
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %46
37: ; preds = %33
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%39 = load i32*, i32** %6
%40 = call i32 @fgets(i8* %38, i32 256, i32* %39)
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%42 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %37
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %33
46: ; preds = %33
%47 = load i32*, i32** %6
%48 = call i32 @fclose(i32* %47)
br label %49
49: ; preds = %46, %11
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"LICENSE.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"print_license: fopen\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define void @print_license(i32 %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
switch i32 %0, label %27 [
i32 0, label %5
i32 1, label %4
]
4: ; preds = %1
br label %5
5: ; preds = %1, %4
%6 = phi i32 [ 625, %4 ], [ 624, %1 ]
%7 = phi i32 [ 70, %4 ], [ 592, %1 ]
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %5, %14
%15 = phi i32 [ %17, %14 ], [ 0, %5 ]
%16 = call i32 @fgets(i8* %3, i32 256, i32* %8)
%17 = add nuw nsw i32 %15, 1
%18 = icmp eq i32 %17, %7
br i1 %18, label %19, label %14
19: ; preds = %14, %19
%20 = phi i32 [ %23, %19 ], [ %7, %14 ]
%21 = call i32 @fgets(i8* %3, i32 256, i32* %8)
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%23 = add nuw nsw i32 %20, 1
%24 = icmp eq i32 %23, %6
br i1 %24, label %25, label %19
25: ; preds = %19
%26 = call i32 @fclose(i32* %8)
br label %27
27: ; preds = %1, %25
ret void
}