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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ __makedev(int, int /*<<< orphan*/);
int atoi(char const *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ create_dev(char *, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *get_arg(int, char **, char *);
scalar_t__ identify_fs(int, char const **, unsigned long long *, int);
int load_ramdisk_compressed(char *, int /*<<< orphan*/ *, int);
int load_ramdisk_raw(char *, int /*<<< orphan*/ *, int, unsigned long long);
int /*<<< orphan*/ name_to_dev_t(char const *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char const *, unsigned long long);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char const *, char *);
int strtoumax(char const *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ wait_for_key();
int ramdisk_load(int argc, char *argv[], dev_t root_dev) {
  const char *arg_prompt_ramdisk = get_arg(argc, argv, "prompt_ramdisk=");
  const char *arg_ramdisk_blocksize = get_arg(argc, argv, "ramdisk_blocksize=");
  const char *arg_ramdisk_start = get_arg(argc, argv, "ramdisk_start=");
  const char *arg_ramdisk_device = get_arg(argc, argv, "ramdisk_device=");
  int prompt_ramdisk = arg_prompt_ramdisk ? atoi(arg_prompt_ramdisk) : 0;
  int ramdisk_blocksize =
      arg_ramdisk_blocksize ? atoi(arg_ramdisk_blocksize) : 512;
  off_t ramdisk_start =
      arg_ramdisk_start
          ? strtoumax(arg_ramdisk_start, NULL, 10) * ramdisk_blocksize
          : 0;
  const char *ramdisk_device =
      arg_ramdisk_device ? arg_ramdisk_device : "/dev/fd0";
  dev_t ramdisk_dev;
  int rfd;
  FILE *wfd;
  const char *fstype;
  unsigned long long fssize;
  int is_gzip = 0;
  int err;
  if (prompt_ramdisk) {
    fprintf(stderr, "Please insert disk for ramdisk and press Enter...");
    wait_for_key();
  }
  ramdisk_dev = name_to_dev_t(ramdisk_device);
  if (!ramdisk_dev) {
    fprintf(stderr, "Failure loading ramdisk: unknown device: %s\n",
            ramdisk_device);
    return 0;
  }
  create_dev("/dev/rddev", ramdisk_dev);
  create_dev("/dev/ram0", __makedev(1, 0));
  rfd = open("/dev/rddev", O_RDONLY);
  wfd = fopen("/dev/ram0", "w");
  if (rfd < 0 || !wfd) {
    perror("Could not open ramdisk device");
    return 0;
  }
  if (identify_fs(rfd, &fstype, &fssize, ramdisk_start) ||
      (fssize == 0 && !(is_gzip = !strcmp(fstype, "gzip")))) {
    fprintf(stderr, "Failure loading ramdisk: unknown filesystem type\n");
    return 0;
  }
  printf("kinit: ramdisk is %s, size %llu\n", fstype, fssize);
  fprintf(stderr, "Loading ramdisk (%s) ...", is_gzip ? "gzip" : "raw");
  close(rfd);
  if (is_gzip)
    err = load_ramdisk_compressed("/dev/rddev", wfd, ramdisk_start);
  else
    err = load_ramdisk_raw("/dev/rddev", wfd, ramdisk_start, fssize);
  fclose(wfd);
  putc('\n', stderr);
  if (err) {
    perror("Failure loading ramdisk");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ramdisk_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdad(%rip),%rdx
call   1070 <get_arg@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xda6(%rip),%rdx
call   1070 <get_arg@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xda2(%rip),%rdx
call   1070 <get_arg@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xd9a(%rip),%rdx
call   1070 <get_arg@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12bd <ramdisk_load+0x8d>
mov    -0x20(%rbp),%rdi
call   1130 <atoi@plt>
mov    %eax,-0x7c(%rbp)
jmp    12c7 <ramdisk_load+0x97>
xor    %eax,%eax
mov    %eax,-0x7c(%rbp)
jmp    12c7 <ramdisk_load+0x97>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12e9 <ramdisk_load+0xb9>
mov    -0x28(%rbp),%rdi
call   1130 <atoi@plt>
mov    %eax,-0x80(%rbp)
jmp    12f6 <ramdisk_load+0xc6>
mov    $0x200,%eax
mov    %eax,-0x80(%rbp)
jmp    12f6 <ramdisk_load+0xc6>
mov    -0x80(%rbp),%eax
mov    %eax,-0x40(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1328 <ramdisk_load+0xf8>
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1120 <strtoumax@plt>
imul   -0x40(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    1335 <ramdisk_load+0x105>
xor    %eax,%eax
mov    %eax,-0x84(%rbp)
jmp    1335 <ramdisk_load+0x105>
mov    -0x84(%rbp),%eax
mov    %eax,-0x44(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1359 <ramdisk_load+0x129>
mov    -0x38(%rbp),%rax
mov    %rax,-0x90(%rbp)
jmp    136c <ramdisk_load+0x13c>
lea    0xce2(%rip),%rax
mov    %rax,-0x90(%rbp)
jmp    136c <ramdisk_load+0x13c>
mov    -0x90(%rbp),%rax
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x74(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     13a6 <ramdisk_load+0x176>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
lea    0xcb3(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    $0x0,%al
call   10e0 <wait_for_key@plt>
mov    -0x50(%rbp),%rdi
call   1090 <name_to_dev_t@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jne    13e3 <ramdisk_load+0x1b3>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rdx
lea    0xcad(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <ramdisk_load+0x37d>
mov    -0x54(%rbp),%esi
lea    0xcbd(%rip),%rdi
call   1150 <create_dev@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1140 <__makedev@plt>
mov    %eax,%esi
lea    0xcae(%rip),%rdi
call   1150 <create_dev@plt>
mov    0x2bd5(%rip),%rax
mov    (%rax),%esi
lea    0xc8e(%rip),%rdi
call   10f0 <open@plt>
mov    %eax,-0x58(%rbp)
lea    0xc8a(%rip),%rdi
lea    0xd1e(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x60(%rbp)
cmpl   $0x0,-0x58(%rbp)
jl     1450 <ramdisk_load+0x220>
cmpq   $0x0,-0x60(%rbp)
jne    1468 <ramdisk_load+0x238>
lea    0xc68(%rip),%rdi
call   1110 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <ramdisk_load+0x37d>
mov    -0x58(%rbp),%edi
mov    -0x44(%rbp),%ecx
lea    -0x68(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   10d0 <identify_fs@plt>
cmp    $0x0,%rax
jne    14bb <ramdisk_load+0x28b>
cmpq   $0x0,-0x70(%rbp)
jne    14de <ramdisk_load+0x2ae>
mov    -0x68(%rbp),%rdi
lea    0xc42(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x74(%rbp)
test   $0x1,%al
jne    14de <ramdisk_load+0x2ae>
mov    0x2b16(%rip),%rax
mov    (%rax),%edi
lea    0xc17(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <ramdisk_load+0x37d>
mov    -0x68(%rbp),%rsi
mov    -0x70(%rbp),%rdx
lea    0xc27(%rip),%rdi
call   1050 <printf@plt>
mov    0x2adf(%rip),%rax
mov    (%rax),%edi
mov    -0x74(%rbp),%ecx
lea    0xc49(%rip),%rdx
lea    0xbd1(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xc1b(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x58(%rbp),%edi
call   1080 <close@plt>
cmpl   $0x0,-0x74(%rbp)
je     154e <ramdisk_load+0x31e>
mov    -0x60(%rbp),%rsi
mov    -0x44(%rbp),%edx
lea    0xb69(%rip),%rdi
call   1030 <load_ramdisk_compressed@plt>
mov    %eax,-0x78(%rbp)
jmp    1568 <ramdisk_load+0x338>
mov    -0x60(%rbp),%rsi
mov    -0x44(%rbp),%edx
mov    -0x70(%rbp),%rcx
lea    0xb4a(%rip),%rdi
call   1060 <load_ramdisk_raw@plt>
mov    %eax,-0x78(%rbp)
mov    -0x60(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2a60(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   10b0 <putc@plt>
cmpl   $0x0,-0x78(%rbp)
je     15a6 <ramdisk_load+0x376>
lea    0xbbd(%rip),%rdi
call   1110 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <ramdisk_load+0x37d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ramdisk_load>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xdb6(%rip),%rdx
call   1070 <get_arg@plt>
mov    %rax,%r14
lea    0xdb7(%rip),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <get_arg@plt>
mov    %rax,%r13
lea    0xdb6(%rip),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <get_arg@plt>
mov    %rax,%r15
lea    0xdb1(%rip),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <get_arg@plt>
mov    %rax,%r12
test   %r14,%r14
je     12ca <ramdisk_load+0x9a>
mov    %r14,%rdi
call   1130 <atoi@plt>
mov    %eax,%r14d
test   %r13,%r13
je     12d2 <ramdisk_load+0xa2>
mov    %r13,%rdi
call   1130 <atoi@plt>
mov    %eax,%ebx
test   %r15,%r15
je     12dc <ramdisk_load+0xac>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1120 <strtoumax@plt>
mov    %eax,%r15d
imul   %ebx,%r15d
jmp    12df <ramdisk_load+0xaf>
xor    %r14d,%r14d
test   %r13,%r13
jne    12a3 <ramdisk_load+0x73>
mov    $0x200,%ebx
test   %r15,%r15
jne    12b2 <ramdisk_load+0x82>
xor    %r15d,%r15d
test   %r12,%r12
lea    0xd59(%rip),%rbx
cmovne %r12,%rbx
test   %r14d,%r14d
je     1310 <ramdisk_load+0xe0>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
lea    0xd49(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
xor    %eax,%eax
call   10e0 <wait_for_key@plt>
mov    %rbx,%rdi
call   1090 <name_to_dev_t@plt>
test   %eax,%eax
je     13bb <ramdisk_load+0x18b>
lea    0xd83(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1150 <create_dev@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1140 <__makedev@plt>
lea    0xd71(%rip),%rbp
mov    %rbp,%rdi
mov    %eax,%esi
call   1150 <create_dev@plt>
mov    0x2c93(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10f0 <open@plt>
mov    %eax,%ebx
lea    0xde8(%rip),%rsi
mov    %rbp,%rdi
call   1100 <fopen@plt>
test   %ebx,%ebx
js     14c9 <ramdisk_load+0x299>
mov    %rax,%r14
test   %rax,%rax
je     14c9 <ramdisk_load+0x299>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
mov    %r15d,%ecx
call   10d0 <identify_fs@plt>
test   %rax,%rax
je     13dc <ramdisk_load+0x1ac>
mov    0x2c34(%rip),%rax
mov    (%rax),%edi
lea    0xd35(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    14d7 <ramdisk_load+0x2a7>
mov    0x2c16(%rip),%rax
mov    (%rax),%edi
lea    0xcb2(%rip),%rsi
xor    %ebp,%ebp
mov    %rbx,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    14d7 <ramdisk_load+0x2a7>
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rbp
test   %rdx,%rdx
je     1465 <ramdisk_load+0x235>
lea    0xd22(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    0x2bd7(%rip),%rax
mov    (%rax),%edi
lea    0xd2b(%rip),%rsi
lea    0xd3d(%rip),%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %ebx,%edi
call   1080 <close@plt>
mov    0x8(%rsp),%rcx
lea    0xc7f(%rip),%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1060 <load_ramdisk_raw@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x2b91(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   10b0 <putc@plt>
mov    $0x1,%ebp
test   %ebx,%ebx
je     14d7 <ramdisk_load+0x2a7>
lea    0xcef(%rip),%rdi
jmp    14d0 <ramdisk_load+0x2a0>
lea    0xc71(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <strcmp@plt>
test   %eax,%eax
jne    139d <ramdisk_load+0x16d>
lea    0xc91(%rip),%rdi
mov    %rbp,%rsi
xor    %edx,%edx
call   1050 <printf@plt>
mov    0x2b44(%rip),%rax
mov    (%rax),%edi
lea    0xc98(%rip),%rsi
lea    0xc39(%rip),%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %ebx,%edi
call   1080 <close@plt>
lea    0xbf1(%rip),%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1030 <load_ramdisk_compressed@plt>
jmp    1436 <ramdisk_load+0x206>
lea    0xbef(%rip),%rdi
call   1110 <perror@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"prompt_ramdisk=\00"
@.str.1 = [19 x i8] c"ramdisk_blocksize=\00"
@.str.2 = [15 x i8] c"ramdisk_start=\00"
@.str.3 = [16 x i8] c"ramdisk_device=\00"
@.str.4 = [9 x i8] c"/dev/fd0\00"
@stderr = global i32 0
@.str.5 = [50 x i8] c"Please insert disk for ramdisk and press Enter...\00"
@.str.6 = [45 x i8] c"Failure loading ramdisk: unknown device: %s\0A\00"
@.str.7 = [11 x i8] c"/dev/rddev\00"
@.str.8 = [10 x i8] c"/dev/ram0\00"
@O_RDONLY = global i32 0
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [30 x i8] c"Could not open ramdisk device\00"
@.str.11 = [5 x i8] c"gzip\00"
@.str.12 = [50 x i8] c"Failure loading ramdisk: unknown filesystem type\0A\00"
@.str.13 = [33 x i8] c"kinit: ramdisk is %s, size %llu\0A\00"
@.str.14 = [25 x i8] c"Loading ramdisk (%s) ...\00"
@.str.15 = [4 x i8] c"raw\00"
@.str.16 = [24 x i8] c"Failure loading ramdisk\00"
define i32 @ramdisk_load(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i8*
%20 = alloca i64
%21 = alloca i32
%22 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%23 = load i32, i32* %5
%24 = load i8**, i8*** %6
%25 = call i8* @get_arg(i32 %23, i8** %24, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i8* %25, i8** %8
%26 = load i32, i32* %5
%27 = load i8**, i8*** %6
%28 = call i8* @get_arg(i32 %26, i8** %27, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i8* %28, i8** %9
%29 = load i32, i32* %5
%30 = load i8**, i8*** %6
%31 = call i8* @get_arg(i32 %29, i8** %30, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i8* %31, i8** %10
%32 = load i32, i32* %5
%33 = load i8**, i8*** %6
%34 = call i8* @get_arg(i32 %32, i8** %33, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i8* %34, i8** %11
%35 = load i8*, i8** %8
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %40
37: ; preds = %3
%38 = load i8*, i8** %8
%39 = call i32 @atoi(i8* %38)
br label %41
40: ; preds = %3
br label %41
41: ; preds = %40, %37
%42 = phi i32 [ %39, %37 ], [ 0, %40 ]
store i32 %42, i32* %12
%43 = load i8*, i8** %9
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i8*, i8** %9
%47 = call i32 @atoi(i8* %46)
br label %49
48: ; preds = %41
br label %49
49: ; preds = %48, %45
%50 = phi i32 [ %47, %45 ], [ 512, %48 ]
store i32 %50, i32* %13
%51 = load i8*, i8** %10
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = load i8*, i8** %10
%55 = call i32 @strtoumax(i8* %54, i32* null, i32 10)
%56 = load i32, i32* %13
%57 = mul nsw i32 %55, %56
br label %59
58: ; preds = %49
br label %59
59: ; preds = %58, %53
%60 = phi i32 [ %57, %53 ], [ 0, %58 ]
store i32 %60, i32* %14
%61 = load i8*, i8** %11
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = load i8*, i8** %11
br label %66
65: ; preds = %59
br label %66
66: ; preds = %65, %63
%67 = phi i8* [ %64, %63 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), %65 ]
store i8* %67, i8** %15
store i32 0, i32* %21
%68 = load i32, i32* %12
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %66
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
%73 = call i32 (...) @wait_for_key()
br label %74
74: ; preds = %70, %66
%75 = load i8*, i8** %15
%76 = call i32 @name_to_dev_t(i8* %75)
store i32 %76, i32* %16
%77 = load i32, i32* %16
%78 = icmp ne i32 %77, 0
br i1 %78, label %83, label %79
79: ; preds = %74
%80 = load i32, i32* @stderr
%81 = load i8*, i8** %15
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i8* %81)
store i32 0, i32* %4
br label %148
83: ; preds = %74
%84 = load i32, i32* %16
%85 = call i32 @create_dev(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %84)
%86 = call i32 @__makedev(i32 1, i32 0)
%87 = call i32 @create_dev(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %86)
%88 = load i32, i32* @O_RDONLY
%89 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %88)
store i32 %89, i32* %17
%90 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %90, i32** %18
%91 = load i32, i32* %17
%92 = icmp slt i32 %91, 0
br i1 %92, label %96, label %93
93: ; preds = %83
%94 = load i32*, i32** %18
%95 = icmp ne i32* %94, null
br i1 %95, label %98, label %96
96: ; preds = %93, %83
%97 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %4
br label %148
98: ; preds = %93
%99 = load i32, i32* %17
%100 = load i32, i32* %14
%101 = call i64 @identify_fs(i32 %99, i8** %19, i64* %20, i32 %100)
%102 = icmp ne i64 %101, 0
br i1 %102, label %112, label %103
103: ; preds = %98
%104 = load i64, i64* %20
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %115
106: ; preds = %103
%107 = load i8*, i8** %19
%108 = call i32 @strcmp(i8* %107, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%109 = icmp ne i32 %108, 0
%110 = xor i1 %109, true
%111 = zext i1 %110 to i32
store i32 %111, i32* %21
br i1 %110, label %115, label %112
112: ; preds = %106, %98
%113 = load i32, i32* @stderr
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %4
br label %148
115: ; preds = %106, %103
%116 = load i8*, i8** %19
%117 = load i64, i64* %20
%118 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), i8* %116, i64 %117)
%119 = load i32, i32* @stderr
%120 = load i32, i32* %21
%121 = icmp ne i32 %120, 0
%122 = zext i1 %121 to i64
%123 = select i1 %121, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0)
%124 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0), i8* %123)
%125 = load i32, i32* %17
%126 = call i32 @close(i32 %125)
%127 = load i32, i32* %21
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %133
129: ; preds = %115
%130 = load i32*, i32** %18
%131 = load i32, i32* %14
%132 = call i32 @load_ramdisk_compressed(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32* %130, i32 %131)
store i32 %132, i32* %22
br label %138
133: ; preds = %115
%134 = load i32*, i32** %18
%135 = load i32, i32* %14
%136 = load i64, i64* %20
%137 = call i32 @load_ramdisk_raw(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32* %134, i32 %135, i64 %136)
store i32 %137, i32* %22
br label %138
138: ; preds = %133, %129
%139 = load i32*, i32** %18
%140 = call i32 @fclose(i32* %139)
%141 = load i32, i32* @stderr
%142 = call i32 @putc(i8 signext 10, i32 %141)
%143 = load i32, i32* %22
%144 = icmp ne i32 %143, 0
br i1 %144, label %145, label %147
145: ; preds = %138
%146 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0))
store i32 0, i32* %4
br label %148
147: ; preds = %138
store i32 1, i32* %4
br label %148
148: ; preds = %147, %145, %112, %96, %79
%149 = load i32, i32* %4
ret i32 %149
}

LLVM IR (-O2):
@.str = [16 x i8] c"prompt_ramdisk=\00"
@.str.1 = [19 x i8] c"ramdisk_blocksize=\00"
@.str.2 = [15 x i8] c"ramdisk_start=\00"
@.str.3 = [16 x i8] c"ramdisk_device=\00"
@.str.4 = [9 x i8] c"/dev/fd0\00"
@stderr = global i32 0
@.str.5 = [50 x i8] c"Please insert disk for ramdisk and press Enter...\00"
@.str.6 = [45 x i8] c"Failure loading ramdisk: unknown device: %s\0A\00"
@.str.7 = [11 x i8] c"/dev/rddev\00"
@.str.8 = [10 x i8] c"/dev/ram0\00"
@O_RDONLY = global i32 0
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [30 x i8] c"Could not open ramdisk device\00"
@.str.11 = [5 x i8] c"gzip\00"
@.str.12 = [50 x i8] c"Failure loading ramdisk: unknown filesystem type\0A\00"
@.str.13 = [33 x i8] c"kinit: ramdisk is %s, size %llu\0A\00"
@.str.14 = [25 x i8] c"Loading ramdisk (%s) ...\00"
@.str.15 = [4 x i8] c"raw\00"
@.str.16 = [24 x i8] c"Failure loading ramdisk\00"
define i32 @ramdisk_load(i32 %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = tail call i8* @get_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = tail call i8* @get_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i8* @get_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i8* @get_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i8* %6, null
br i1 %10, label %13, label %11
11: ; preds = %3
%12 = tail call i32 @atoi(i8* %6)
br label %13
13: ; preds = %3, %11
%14 = phi i32 [ %12, %11 ], [ 0, %3 ]
%15 = icmp eq i8* %7, null
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 @atoi(i8* %7)
br label %18
18: ; preds = %13, %16
%19 = phi i32 [ %17, %16 ], [ 512, %13 ]
%20 = icmp eq i8* %8, null
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = tail call i32 @strtoumax(i8* %8, i32* null, i32 10)
%23 = mul nsw i32 %22, %19
br label %24
24: ; preds = %18, %21
%25 = phi i32 [ %23, %21 ], [ 0, %18 ]
%26 = icmp eq i8* %9, null
%27 = select i1 %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %9
%28 = bitcast i8** %4 to i8*
%29 = bitcast i64* %5 to i8*
%30 = icmp eq i32 %14, 0
br i1 %30, label %35, label %31
31: ; preds = %24
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
%34 = tail call i32 (...) @wait_for_key()
br label %35
35: ; preds = %31, %24
%36 = tail call i32 @name_to_dev_t(i8* %27)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i8* %27)
br label %87
41: ; preds = %35
%42 = tail call i32 @create_dev(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %36)
%43 = tail call i32 @__makedev(i32 1, i32 0)
%44 = tail call i32 @create_dev(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 %43)
%45 = load i32, i32* @O_RDONLY
%46 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %45)
%47 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%48 = icmp sgt i32 %46, -1
%49 = icmp ne i32* %47, null
%50 = and i1 %48, %49
br i1 %50, label %53, label %51
51: ; preds = %41
%52 = tail call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
br label %87
53: ; preds = %41
%54 = call i64 @identify_fs(i32 %46, i8** %4, i64* %5, i32 %25)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %63
56: ; preds = %53
%57 = load i64, i64* %5
%58 = icmp eq i64 %57, 0
%59 = load i8*, i8** %4
br i1 %58, label %60, label %72
60: ; preds = %56
%61 = call i32 @strcmp(i8* dereferenceable(1) %59, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%62 = icmp eq i32 %61, 0
br i1 %62, label %66, label %63
63: ; preds = %60, %53
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.12, i64 0, i64 0))
br label %87
66: ; preds = %60
%67 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), i8* %59, i64 0)
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%70 = call i32 @close(i32 %46)
%71 = call i32 @load_ramdisk_compressed(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32* %47, i32 %25)
br label %79
72: ; preds = %56
%73 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), i8* %59, i64 %57)
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0))
%76 = call i32 @close(i32 %46)
%77 = load i64, i64* %5
%78 = call i32 @load_ramdisk_raw(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32* %47, i32 %25, i64 %77)
br label %79
79: ; preds = %72, %66
%80 = phi i32 [ %71, %66 ], [ %78, %72 ]
%81 = call i32 @fclose(i32* %47)
%82 = load i32, i32* @stderr
%83 = call i32 @putc(i8 signext 10, i32 %82)
%84 = icmp eq i32 %80, 0
br i1 %84, label %87, label %85
85: ; preds = %79
%86 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0))
br label %87
87: ; preds = %79, %85, %63, %51, %38
%88 = phi i32 [ 0, %63 ], [ 0, %85 ], [ 0, %51 ], [ 0, %38 ], [ 1, %79 ]
ret i32 %88
}