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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
int sscanf(char *, char *, char *, char *, char *, int *, char *);
int /*<<< orphan*/ strcmp(char const *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int support_gpt();
int partition_info(const char *partition_name, char *part_dev_path,
                   int *storage_type) {
  int result = 0;
  if (!strcmp(partition_name, "logo") || !strcmp(partition_name, "preloader") ||
      !strcmp(partition_name, "uboot") || !strcmp(partition_name, "dsp_bl") ||
      !strcmp(partition_name, "bootimg") || !strcmp(partition_name, "boot") ||
      !strcmp(partition_name, "tee1") || !strcmp(partition_name, "recovery")) {
    bool is_gpt = support_gpt();
    if (is_gpt) {
      if (!strcmp(partition_name, "preloader")) {
        strcpy(part_dev_path, "/dev/block/mmcblk0boot0");
      } else if (!strcmp(partition_name, "bootimg")) {
        strcpy(part_dev_path, "/dev/block/platform/mtk-msdc.0/by-name/boot");
      } else if (!strcmp(partition_name, "logo")) {
        strcpy(part_dev_path, "/dev/block/platform/mtk-msdc.0/by-name/logo");
      } else if (!strcmp(partition_name, "uboot")) {
        strcpy(part_dev_path, "/dev/block/platform/mtk-msdc.0/by-name/lk");
      } else if (!strcmp(partition_name, "tee1")) {
        strcpy(part_dev_path, "/dev/block/platform/mtk-msdc.0/by-name/tee1");
      } else if (!strcmp(partition_name, "recovery")) {
        strcpy(part_dev_path,
               "/dev/block/platform/mtk-msdc.0/by-name/recovery");
      }
      *storage_type = 2;
    } else {
      FILE *fp = fopen("/proc/dumchar_info", "r");
      if (fp) {
        char buf[512], p_name[32], p_size[32], p_addr[32], p_actname[64];
        int p_type = 0;
        if (fgets(buf, sizeof(buf), fp) == NULL) {
          fclose(fp);
          result = -1;
        } else {
          while (fgets(buf, sizeof(buf), fp)) {
            if (sscanf(buf, "%s %s %s %d %s", p_name, p_size, p_addr, &p_type,
                       p_actname) == 5) {
              if (!strcmp(p_name, "bmtpool")) {
                break;
              }
              *storage_type = p_type;
              if (p_type == 2) {
                snprintf(part_dev_path, 128, "/dev/%s", partition_name);
                break;
              } else if (p_type == 1) {
                if (!strcmp(partition_name, "boot") ||
                    !strcmp(partition_name, "bootimg"))
                  strcpy(part_dev_path, "boot");
                else
                  strcpy(part_dev_path, partition_name);
                break;
              } else
                result = -2;
            }
          }
          fclose(fp);
        }
      } else {
        result = -1;
      }
    }
  } else {
    result = -2;
  }
  return result;
}


x86 assembly (clang, -O0):
<partition_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2e0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xee1(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1266 <partition_info+0xe6>
mov    -0x8(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1266 <partition_info+0xe6>
mov    -0x8(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1266 <partition_info+0xe6>
mov    -0x8(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1266 <partition_info+0xe6>
mov    -0x8(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1266 <partition_info+0xe6>
mov    -0x8(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1266 <partition_info+0xe6>
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1266 <partition_info+0xe6>
mov    -0x8(%rbp),%rdi
lea    0xeb4(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    156b <partition_info+0x3eb>
mov    $0x0,%al
call   1080 <support_gpt@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     13b1 <partition_info+0x231>
mov    -0x8(%rbp),%rdi
lea    0xd7b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12a8 <partition_info+0x128>
mov    -0x10(%rbp),%rdi
lea    0xd81(%rip),%rsi
call   1030 <strcpy@plt>
jmp    13a2 <partition_info+0x222>
mov    -0x8(%rbp),%rdi
lea    0xd64(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12d6 <partition_info+0x156>
mov    -0x10(%rbp),%rdi
lea    0xd6b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    139d <partition_info+0x21d>
mov    -0x8(%rbp),%rdi
lea    0xda9(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1304 <partition_info+0x184>
mov    -0x10(%rbp),%rdi
lea    0xd69(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1398 <partition_info+0x218>
mov    -0x8(%rbp),%rdi
lea    0xcfb(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1332 <partition_info+0x1b2>
mov    -0x10(%rbp),%rdi
lea    0xd67(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1393 <partition_info+0x213>
mov    -0x8(%rbp),%rdi
lea    0xda3(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1360 <partition_info+0x1e0>
mov    -0x10(%rbp),%rdi
lea    0xd63(%rip),%rsi
call   1030 <strcpy@plt>
jmp    138e <partition_info+0x20e>
mov    -0x8(%rbp),%rdi
lea    0xda1(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1389 <partition_info+0x209>
mov    -0x10(%rbp),%rdi
lea    0xd61(%rip),%rsi
call   1030 <strcpy@plt>
jmp    138e <partition_info+0x20e>
jmp    1393 <partition_info+0x213>
jmp    1398 <partition_info+0x218>
jmp    139d <partition_info+0x21d>
jmp    13a2 <partition_info+0x222>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
jmp    1566 <partition_info+0x3e6>
lea    0xd5d(%rip),%rdi
lea    0xc49(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     155a <partition_info+0x3da>
movl   $0x0,-0x2d4(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x200,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1411 <partition_info+0x291>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0xffffffff,-0x1c(%rbp)
jmp    1555 <partition_info+0x3d5>
jmp    1416 <partition_info+0x296>
lea    -0x230(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x200,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     154c <partition_info+0x3cc>
lea    -0x230(%rbp),%rdi
lea    -0x250(%rbp),%rdx
lea    -0x270(%rbp),%rcx
lea    -0x290(%rbp),%r8
lea    -0x2d0(%rbp),%rax
lea    0xcc9(%rip),%rsi
lea    -0x2d4(%rbp),%r9
mov    %rax,(%rsp)
call   1090 <sscanf@plt>
cmp    $0x5,%eax
jne    1547 <partition_info+0x3c7>
lea    -0x250(%rbp),%rdi
lea    0xcb1(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1499 <partition_info+0x319>
jmp    154c <partition_info+0x3cc>
mov    -0x2d4(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x2,-0x2d4(%rbp)
jne    14d0 <partition_info+0x350>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x80,%esi
lea    0xc79(%rip),%rdx
call   1050 <snprintf@plt>
jmp    154c <partition_info+0x3cc>
cmpl   $0x1,-0x2d4(%rbp)
jne    1536 <partition_info+0x3b6>
mov    -0x8(%rbp),%rdi
lea    0xb76(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     150f <partition_info+0x38f>
mov    -0x8(%rbp),%rdi
lea    0xb16(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1524 <partition_info+0x3a4>
mov    -0x10(%rbp),%rdi
lea    0xb44(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1531 <partition_info+0x3b1>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    154c <partition_info+0x3cc>
movl   $0xfffffffe,-0x1c(%rbp)
jmp    1542 <partition_info+0x3c2>
jmp    1547 <partition_info+0x3c7>
jmp    1416 <partition_info+0x296>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1561 <partition_info+0x3e1>
movl   $0xffffffff,-0x1c(%rbp)
jmp    1566 <partition_info+0x3e6>
jmp    1572 <partition_info+0x3f2>
movl   $0xfffffffe,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<partition_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2c8,%rsp
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xee9(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     123d <partition_info+0xbd>
lea    0xe4b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     123d <partition_info+0xbd>
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     123d <partition_info+0xbd>
lea    0xe35(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     123d <partition_info+0xbd>
lea    0xe29(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     123d <partition_info+0xbd>
lea    0xe5d(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     123d <partition_info+0xbd>
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     123d <partition_info+0xbd>
lea    0xee5(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
mov    $0xfffffffe,%r13d
test   %eax,%eax
jne    14ba <partition_info+0x33a>
xor    %eax,%eax
call   1080 <support_gpt@plt>
test   %eax,%eax
je     12e2 <partition_info+0x162>
lea    0xdad(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1417 <partition_info+0x297>
lea    0xdad(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1420 <partition_info+0x2a0>
lea    0xe09(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1434 <partition_info+0x2b4>
lea    0xd72(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1445 <partition_info+0x2c5>
lea    0xe31(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1453 <partition_info+0x2d3>
lea    0xe46(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    1462 <partition_info+0x2e2>
lea    0xe08(%rip),%rsi
jmp    145a <partition_info+0x2da>
lea    0xe2c(%rip),%rdi
lea    0xd18(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1429 <partition_info+0x2a9>
mov    %rax,%r12
movl   $0x0,0xc(%rsp)
lea    0xc0(%rsp),%rdi
mov    $0x200,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     143d <partition_info+0x2bd>
lea    0xc0(%rsp),%rdi
mov    $0x200,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     144e <partition_info+0x2ce>
mov    %r14,0x18(%rsp)
mov    %rbp,0x10(%rsp)
xor    %r14d,%r14d
lea    0xc0(%rsp),%rbp
lea    0xc(%rsp),%r15
jmp    138f <partition_info+0x20f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%r13d
mov    %rbp,%rdi
mov    $0x200,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
mov    %r13d,%r14d
test   %rax,%rax
je     14b2 <partition_info+0x332>
lea    0x80(%rsp),%rax
mov    %rax,(%rsp)
mov    %rbp,%rdi
lea    0xd83(%rip),%rsi
lea    0x20(%rsp),%rdx
lea    0x60(%rsp),%rcx
lea    0x40(%rsp),%r8
mov    %r15,%r9
call   1090 <sscanf@plt>
cmp    $0x5,%eax
jne    1370 <partition_info+0x1f0>
movabs $0x6c6f6f70746d62,%rax
cmp    %rax,0x20(%rsp)
je     14af <partition_info+0x32f>
mov    0xc(%rsp),%eax
mov    0x18(%rsp),%rcx
mov    %eax,(%rcx)
cmp    $0x1,%eax
je     146e <partition_info+0x2ee>
mov    $0xfffffffe,%r13d
cmp    $0x2,%eax
jne    1373 <partition_info+0x1f3>
lea    0xd37(%rip),%rdx
mov    0x10(%rsp),%rdi
mov    $0x80,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
jmp    14af <partition_info+0x32f>
lea    0xc01(%rip),%rsi
jmp    145a <partition_info+0x2da>
lea    0xc10(%rip),%rsi
jmp    145a <partition_info+0x2da>
mov    $0xffffffff,%r13d
jmp    14ba <partition_info+0x33a>
lea    0xc28(%rip),%rsi
jmp    145a <partition_info+0x2da>
mov    $0xffffffff,%r13d
jmp    14b2 <partition_info+0x332>
lea    0xc43(%rip),%rsi
jmp    145a <partition_info+0x2da>
xor    %r13d,%r13d
jmp    14b2 <partition_info+0x332>
lea    0xc5f(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcpy@plt>
movl   $0x2,(%r14)
xor    %r13d,%r13d
jmp    14ba <partition_info+0x33a>
lea    0xbe9(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     149e <partition_info+0x31e>
lea    0xb8f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     149e <partition_info+0x31e>
mov    0x10(%rsp),%rdi
mov    %rbx,%rsi
jmp    14aa <partition_info+0x32a>
lea    0xbb9(%rip),%rsi
mov    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
mov    %r14d,%r13d
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %r13d,%eax
add    $0x2c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"logo\00"
@.str.1 = [10 x i8] c"preloader\00"
@.str.2 = [6 x i8] c"uboot\00"
@.str.3 = [7 x i8] c"dsp_bl\00"
@.str.4 = [8 x i8] c"bootimg\00"
@.str.5 = [5 x i8] c"boot\00"
@.str.6 = [5 x i8] c"tee1\00"
@.str.7 = [9 x i8] c"recovery\00"
@.str.8 = [24 x i8] c"/dev/block/mmcblk0boot0\00"
@.str.9 = [44 x i8] c"/dev/block/platform/mtk-msdc.0/by-name/boot\00"
@.str.10 = [44 x i8] c"/dev/block/platform/mtk-msdc.0/by-name/logo\00"
@.str.11 = [42 x i8] c"/dev/block/platform/mtk-msdc.0/by-name/lk\00"
@.str.12 = [44 x i8] c"/dev/block/platform/mtk-msdc.0/by-name/tee1\00"
@.str.13 = [48 x i8] c"/dev/block/platform/mtk-msdc.0/by-name/recovery\00"
@.str.14 = [19 x i8] c"/proc/dumchar_info\00"
@.str.15 = [2 x i8] c"r\00"
@.str.16 = [15 x i8] c"%s %s %s %d %s\00"
@.str.17 = [8 x i8] c"bmtpool\00"
@.str.18 = [8 x i8] c"/dev/%s\00"
define i32 @partition_info(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [512 x i8]
%11 = alloca [32 x i8]
%12 = alloca [32 x i8]
%13 = alloca [32 x i8]
%14 = alloca [64 x i8]
%15 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
store i32 0, i32* %7
%16 = load i8*, i8** %4
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %47
19: ; preds = %3
%20 = load i8*, i8** %4
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %47
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %47
27: ; preds = %23
%28 = load i8*, i8** %4
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %47
31: ; preds = %27
%32 = load i8*, i8** %4
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %47
35: ; preds = %31
%36 = load i8*, i8** %4
%37 = call i32 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %47
39: ; preds = %35
%40 = load i8*, i8** %4
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load i8*, i8** %4
%45 = call i32 @strcmp(i8* %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%46 = icmp ne i32 %45, 0
br i1 %46, label %170, label %47
47: ; preds = %43, %39, %35, %31, %27, %23, %19, %3
%48 = call i32 (...) @support_gpt()
store i32 %48, i32* %8
%49 = load i32, i32* %8
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %100
51: ; preds = %47
%52 = load i8*, i8** %4
%53 = call i32 @strcmp(i8* %52, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%54 = icmp ne i32 %53, 0
br i1 %54, label %58, label %55
55: ; preds = %51
%56 = load i8*, i8** %5
%57 = call i32 @strcpy(i8* %56, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %98
58: ; preds = %51
%59 = load i8*, i8** %4
%60 = call i32 @strcmp(i8* %59, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%61 = icmp ne i32 %60, 0
br i1 %61, label %65, label %62
62: ; preds = %58
%63 = load i8*, i8** %5
%64 = call i32 @strcpy(i8* %63, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0))
br label %97
65: ; preds = %58
%66 = load i8*, i8** %4
%67 = call i32 @strcmp(i8* %66, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%68 = icmp ne i32 %67, 0
br i1 %68, label %72, label %69
69: ; preds = %65
%70 = load i8*, i8** %5
%71 = call i32 @strcpy(i8* %70, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0))
br label %96
72: ; preds = %65
%73 = load i8*, i8** %4
%74 = call i32 @strcmp(i8* %73, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%75 = icmp ne i32 %74, 0
br i1 %75, label %79, label %76
76: ; preds = %72
%77 = load i8*, i8** %5
%78 = call i32 @strcpy(i8* %77, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0))
br label %95
79: ; preds = %72
%80 = load i8*, i8** %4
%81 = call i32 @strcmp(i8* %80, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%82 = icmp ne i32 %81, 0
br i1 %82, label %86, label %83
83: ; preds = %79
%84 = load i8*, i8** %5
%85 = call i32 @strcpy(i8* %84, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.12, i64 0, i64 0))
br label %94
86: ; preds = %79
%87 = load i8*, i8** %4
%88 = call i32 @strcmp(i8* %87, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%89 = icmp ne i32 %88, 0
br i1 %89, label %93, label %90
90: ; preds = %86
%91 = load i8*, i8** %5
%92 = call i32 @strcpy(i8* %91, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.13, i64 0, i64 0))
br label %93
93: ; preds = %90, %86
br label %94
94: ; preds = %93, %83
br label %95
95: ; preds = %94, %76
br label %96
96: ; preds = %95, %69
br label %97
97: ; preds = %96, %62
br label %98
98: ; preds = %97, %55
%99 = load i32*, i32** %6
store i32 2, i32* %99
br label %169
100: ; preds = %47
%101 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32* %101, i32** %9
%102 = load i32*, i32** %9
%103 = icmp ne i32* %102, null
br i1 %103, label %104, label %167
104: ; preds = %100
store i32 0, i32* %15
%105 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%106 = load i32*, i32** %9
%107 = call i32* @fgets(i8* %105, i32 512, i32* %106)
%108 = icmp eq i32* %107, null
br i1 %108, label %109, label %112
109: ; preds = %104
%110 = load i32*, i32** %9
%111 = call i32 @fclose(i32* %110)
store i32 -1, i32* %7
br label %166
112: ; preds = %104
br label %113
113: ; preds = %162, %112
%114 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%115 = load i32*, i32** %9
%116 = call i32* @fgets(i8* %114, i32 512, i32* %115)
%117 = icmp ne i32* %116, null
br i1 %117, label %118, label %163
118: ; preds = %113
%119 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%120 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%121 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%122 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%123 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%124 = call i32 @sscanf(i8* %119, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.16, i64 0, i64 0), i8* %120, i8* %121, i8* %122, i32* %15, i8* %123)
%125 = icmp eq i32 %124, 5
br i1 %125, label %126, label %162
126: ; preds = %118
%127 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%128 = call i32 @strcmp(i8* %127, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0))
%129 = icmp ne i32 %128, 0
br i1 %129, label %131, label %130
130: ; preds = %126
br label %163
131: ; preds = %126
%132 = load i32, i32* %15
%133 = load i32*, i32** %6
store i32 %132, i32* %133
%134 = load i32, i32* %15
%135 = icmp eq i32 %134, 2
br i1 %135, label %136, label %140
136: ; preds = %131
%137 = load i8*, i8** %5
%138 = load i8*, i8** %4
%139 = call i32 @snprintf(i8* %137, i32 128, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i8* %138)
br label %163
140: ; preds = %131
%141 = load i32, i32* %15
%142 = icmp eq i32 %141, 1
br i1 %142, label %143, label %159
143: ; preds = %140
%144 = load i8*, i8** %4
%145 = call i32 @strcmp(i8* %144, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%146 = icmp ne i32 %145, 0
br i1 %146, label %147, label %151
147: ; preds = %143
%148 = load i8*, i8** %4
%149 = call i32 @strcmp(i8* %148, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%150 = icmp ne i32 %149, 0
br i1 %150, label %154, label %151
151: ; preds = %147, %143
%152 = load i8*, i8** %5
%153 = call i32 @strcpy(i8* %152, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %158
154: ; preds = %147
%155 = load i8*, i8** %5
%156 = load i8*, i8** %4
%157 = call i32 @strcpy(i8* %155, i8* %156)
br label %158
158: ; preds = %154, %151
br label %163
159: ; preds = %140
store i32 -2, i32* %7
br label %160
160: ; preds = %159
br label %161
161: ; preds = %160
br label %162
162: ; preds = %161, %118
br label %113
163: ; preds = %158, %136, %130, %113
%164 = load i32*, i32** %9
%165 = call i32 @fclose(i32* %164)
br label %166
166: ; preds = %163, %109
br label %168
167: ; preds = %100
store i32 -1, i32* %7
br label %168
168: ; preds = %167, %166
br label %169
169: ; preds = %168, %98
br label %171
170: ; preds = %43
store i32 -2, i32* %7
br label %171
171: ; preds = %170, %169
%172 = load i32, i32* %7
ret i32 %172
}

LLVM IR (-O2):
@.str = [5 x i8] c"logo\00"
@.str.1 = [10 x i8] c"preloader\00"
@.str.2 = [6 x i8] c"uboot\00"
@.str.3 = [7 x i8] c"dsp_bl\00"
@.str.4 = [8 x i8] c"bootimg\00"
@.str.5 = [5 x i8] c"boot\00"
@.str.6 = [5 x i8] c"tee1\00"
@.str.7 = [9 x i8] c"recovery\00"
@.str.8 = [24 x i8] c"/dev/block/mmcblk0boot0\00"
@.str.9 = [44 x i8] c"/dev/block/platform/mtk-msdc.0/by-name/boot\00"
@.str.10 = [44 x i8] c"/dev/block/platform/mtk-msdc.0/by-name/logo\00"
@.str.11 = [42 x i8] c"/dev/block/platform/mtk-msdc.0/by-name/lk\00"
@.str.12 = [44 x i8] c"/dev/block/platform/mtk-msdc.0/by-name/tee1\00"
@.str.13 = [48 x i8] c"/dev/block/platform/mtk-msdc.0/by-name/recovery\00"
@.str.14 = [19 x i8] c"/proc/dumchar_info\00"
@.str.15 = [2 x i8] c"r\00"
@.str.16 = [15 x i8] c"%s %s %s %d %s\00"
@.str.18 = [8 x i8] c"/dev/%s\00"
define i32 @partition_info(i8* %0, i8* %1, i32* nocapture writeonly %2) {
%4 = alloca [512 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca [32 x i8]
%8 = alloca [64 x i8]
%9 = alloca i32
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %33, label %12
12: ; preds = %3
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %33, label %15
15: ; preds = %12
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %33, label %18
18: ; preds = %15
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %33, label %21
21: ; preds = %18
%22 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %33, label %24
24: ; preds = %21
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %103
33: ; preds = %30, %27, %24, %21, %18, %15, %12, %3
%34 = tail call i32 (...) @support_gpt()
%35 = icmp eq i32 %34, 0
br i1 %35, label %58, label %36
36: ; preds = %33
%37 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %54, label %39
39: ; preds = %36
%40 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%41 = icmp eq i32 %40, 0
br i1 %41, label %54, label %42
42: ; preds = %39
%43 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%44 = icmp eq i32 %43, 0
br i1 %44, label %54, label %45
45: ; preds = %42
%46 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%47 = icmp eq i32 %46, 0
br i1 %47, label %54, label %48
48: ; preds = %45
%49 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%50 = icmp eq i32 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %51, %48, %45, %42, %39, %36
%55 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), %36 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), %39 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), %42 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0), %45 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.12, i64 0, i64 0), %48 ], [ getelementptr inbounds ([48 x i8], [48 x i8]* @.str.13, i64 0, i64 0), %51 ]
%56 = tail call i32 @strcpy(i8* %1, i8* %55)
br label %57
57: ; preds = %54, %51
store i32 2, i32* %2
br label %103
58: ; preds = %33
%59 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%60 = icmp eq i32* %59, null
br i1 %60, label %103, label %61
61: ; preds = %58
%62 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%63 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%64 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%65 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%66 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%67 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%68 = call i32* @fgets(i8* %62, i32 512, i32* %59)
%69 = icmp eq i32* %68, null
br i1 %69, label %100, label %70
70: ; preds = %61
%71 = call i32* @fgets(i8* %62, i32 512, i32* %59)
%72 = icmp eq i32* %71, null
br i1 %72, label %100, label %73
73: ; preds = %70
%74 = bitcast [32 x i8]* %5 to i64*
br label %75
75: ; preds = %73, %96
%76 = phi i32 [ 0, %73 ], [ %97, %96 ]
%77 = call i32 @sscanf(i8* %62, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.16, i64 0, i64 0), i8* %63, i8* %64, i8* %65, i32* %9, i8* %66)
%78 = icmp eq i32 %77, 5
br i1 %78, label %79, label %96
79: ; preds = %75
%80 = load i64, i64* %74
%81 = icmp eq i64 %80, 30521821903482210
br i1 %81, label %100, label %82
82: ; preds = %79
%83 = load i32, i32* %9
store i32 %83, i32* %2
switch i32 %83, label %96 [
i32 2, label %84
i32 1, label %86
]
84: ; preds = %82
%85 = call i32 @snprintf(i8* %1, i32 128, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i8* %0)
br label %100
86: ; preds = %82
%87 = call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%88 = icmp eq i32 %87, 0
br i1 %88, label %92, label %89
89: ; preds = %86
%90 = call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %89, %86
%93 = call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %100
94: ; preds = %89
%95 = call i32 @strcpy(i8* %1, i8* %0)
br label %100
96: ; preds = %82, %75
%97 = phi i32 [ %76, %75 ], [ -2, %82 ]
%98 = call i32* @fgets(i8* %62, i32 512, i32* %59)
%99 = icmp eq i32* %98, null
br i1 %99, label %100, label %75
100: ; preds = %79, %96, %84, %94, %92, %70, %61
%101 = phi i32 [ -1, %61 ], [ %76, %92 ], [ %76, %94 ], [ %76, %84 ], [ 0, %70 ], [ %97, %96 ], [ %76, %79 ]
%102 = call i32 @fclose(i32* %59)
br label %103
103: ; preds = %30, %57, %58, %100
%104 = phi i32 [ 0, %57 ], [ %101, %100 ], [ -1, %58 ], [ -2, %30 ]
ret i32 %104
}