#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 */

/* Variables and functions */
scalar_t__ partition_label_match(int, char const *);
scalar_t__ partition_size(int);
long long int get_offset_of_partition(const char *label) {
  int part_index = 0, i = 0;
  long long int offset = 0;
  for (i = 0; i < 10; ++i) {
    if (partition_label_match(i, label)) {
      break;
    }
    offset += partition_size(i);
  }
  return offset;
}


x86 assembly (clang, -O0):
<get_offset_of_partition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    118c <get_offset_of_partition+0x6c>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <partition_label_match@plt>
cmp    $0x0,%rax
je     116e <get_offset_of_partition+0x4e>
jmp    118c <get_offset_of_partition+0x6c>
mov    -0x10(%rbp),%edi
call   1040 <partition_size@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1149 <get_offset_of_partition+0x29>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_offset_of_partition>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %r15d,%r15d
xor    %edi,%edi
mov    %r14,%rsi
call   1030 <partition_label_match@plt>
test   %rax,%rax
jne    1279 <get_offset_of_partition+0x159>
xor    %edi,%edi
call   1040 <partition_size@plt>
mov    %rax,%rbx
mov    $0x1,%edi
mov    %r14,%rsi
call   1030 <partition_label_match@plt>
mov    %rbx,%r15
test   %rax,%rax
jne    1279 <get_offset_of_partition+0x159>
mov    $0x1,%edi
call   1040 <partition_size@plt>
mov    %rax,%r15
add    %rbx,%r15
mov    $0x2,%edi
mov    %r14,%rsi
call   1030 <partition_label_match@plt>
test   %rax,%rax
jne    1279 <get_offset_of_partition+0x159>
mov    $0x2,%edi
call   1040 <partition_size@plt>
add    %rax,%r15
mov    $0x3,%edi
mov    %r14,%rsi
call   1030 <partition_label_match@plt>
test   %rax,%rax
jne    1279 <get_offset_of_partition+0x159>
mov    $0x3,%edi
call   1040 <partition_size@plt>
add    %rax,%r15
mov    $0x4,%edi
mov    %r14,%rsi
call   1030 <partition_label_match@plt>
test   %rax,%rax
jne    1279 <get_offset_of_partition+0x159>
mov    $0x4,%edi
call   1040 <partition_size@plt>
add    %rax,%r15
mov    $0x5,%edi
mov    %r14,%rsi
call   1030 <partition_label_match@plt>
test   %rax,%rax
jne    1279 <get_offset_of_partition+0x159>
mov    $0x5,%edi
call   1040 <partition_size@plt>
add    %rax,%r15
mov    $0x6,%edi
mov    %r14,%rsi
call   1030 <partition_label_match@plt>
test   %rax,%rax
jne    1279 <get_offset_of_partition+0x159>
mov    $0x6,%edi
call   1040 <partition_size@plt>
add    %rax,%r15
mov    $0x7,%edi
mov    %r14,%rsi
call   1030 <partition_label_match@plt>
test   %rax,%rax
jne    1279 <get_offset_of_partition+0x159>
mov    $0x7,%edi
call   1040 <partition_size@plt>
add    %rax,%r15
mov    $0x8,%edi
mov    %r14,%rsi
call   1030 <partition_label_match@plt>
test   %rax,%rax
jne    1279 <get_offset_of_partition+0x159>
mov    $0x8,%edi
call   1040 <partition_size@plt>
add    %rax,%r15
mov    $0x9,%edi
mov    %r14,%rsi
call   1030 <partition_label_match@plt>
test   %rax,%rax
jne    1279 <get_offset_of_partition+0x159>
mov    $0x9,%edi
call   1040 <partition_size@plt>
add    %rax,%r15
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @get_offset_of_partition(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i64 0, i64* %5
store i32 0, i32* %4
br label %6
6: ; preds = %20, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i32, i32* %4
%11 = load i8*, i8** %2
%12 = call i64 @partition_label_match(i32 %10, i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
br label %23
15: ; preds = %9
%16 = load i32, i32* %4
%17 = call i64 @partition_size(i32 %16)
%18 = load i64, i64* %5
%19 = add nsw i64 %18, %17
store i64 %19, i64* %5
br label %20
20: ; preds = %15
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %6
23: ; preds = %14, %6
%24 = load i64, i64* %5
ret i64 %24
}

LLVM IR (-O2):
define i64 @get_offset_of_partition(i8* %0) {
%2 = tail call i64 @partition_label_match(i32 0, i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %51
4: ; preds = %1
%5 = tail call i64 @partition_size(i32 0)
%6 = tail call i64 @partition_label_match(i32 1, i8* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %51
8: ; preds = %4
%9 = tail call i64 @partition_size(i32 1)
%10 = add nsw i64 %9, %5
%11 = tail call i64 @partition_label_match(i32 2, i8* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %51
13: ; preds = %8
%14 = tail call i64 @partition_size(i32 2)
%15 = add nsw i64 %14, %10
%16 = tail call i64 @partition_label_match(i32 3, i8* %0)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %51
18: ; preds = %13
%19 = tail call i64 @partition_size(i32 3)
%20 = add nsw i64 %19, %15
%21 = tail call i64 @partition_label_match(i32 4, i8* %0)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %51
23: ; preds = %18
%24 = tail call i64 @partition_size(i32 4)
%25 = add nsw i64 %24, %20
%26 = tail call i64 @partition_label_match(i32 5, i8* %0)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %51
28: ; preds = %23
%29 = tail call i64 @partition_size(i32 5)
%30 = add nsw i64 %29, %25
%31 = tail call i64 @partition_label_match(i32 6, i8* %0)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %51
33: ; preds = %28
%34 = tail call i64 @partition_size(i32 6)
%35 = add nsw i64 %34, %30
%36 = tail call i64 @partition_label_match(i32 7, i8* %0)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %51
38: ; preds = %33
%39 = tail call i64 @partition_size(i32 7)
%40 = add nsw i64 %39, %35
%41 = tail call i64 @partition_label_match(i32 8, i8* %0)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %51
43: ; preds = %38
%44 = tail call i64 @partition_size(i32 8)
%45 = add nsw i64 %44, %40
%46 = tail call i64 @partition_label_match(i32 9, i8* %0)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %43
%49 = tail call i64 @partition_size(i32 9)
%50 = add nsw i64 %49, %45
br label %51
51: ; preds = %48, %43, %38, %33, %28, %23, %18, %13, %8, %4, %1
%52 = phi i64 [ 0, %1 ], [ %5, %4 ], [ %10, %8 ], [ %15, %13 ], [ %20, %18 ], [ %25, %23 ], [ %30, %28 ], [ %35, %33 ], [ %40, %38 ], [ %45, %43 ], [ %50, %48 ]
ret i64 %52
}