#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 */
int /*<<< orphan*/ get_totals(char *, char *, int, int, char *, double *,
                              double *);
scalar_t__ malloc(int);
int parse_search_string(char *, char, char, int, char *, char *);
int strlen(char *);
char toupper(char);
int calc_piechart(char *account, char *search_string, int month_number,
                  int year, char field_separator, char *currency, int spending,
                  char **fieldname, double *value, double *total_value,
                  int max_fields, int include_zeros) {
  double total_receive = 0, total_spend = 0;
  int start_index = 0, i, j;
  char search[1024];
  char name[1024];
  int field_ctr = 0;
  *total_value = 0;
  while (start_index < strlen(search_string)) {
    start_index =
        parse_search_string(search_string, ',', '|', start_index, search, name);
    get_totals(account, search, month_number, year, currency, &total_receive,
               &total_spend);
    if (spending != 0)
      value[field_ctr] = total_spend;
    else
      value[field_ctr] = total_receive;
    *total_value += value[field_ctr];
    fieldname[field_ctr] = (char *)malloc(1024);
    fieldname[field_ctr][0] = 0;
    if (name[0] != 0) {
      for (i = 0; i < strlen(name); i++) {
        fieldname[field_ctr][i] = name[i];
      }
      fieldname[field_ctr][i] = 0;
    } else {
      j = 0;
      for (i = 0; i < strlen(search); i++)
        if ((search[i] != '*') && (search[i] != '%'))
          fieldname[field_ctr][j++] = search[i];
      fieldname[field_ctr][j] = 0;
    }
    if (fieldname[field_ctr][0] != 0)
      fieldname[field_ctr][0] = toupper(fieldname[field_ctr][0]);
    if ((include_zeros != 0) ||
        ((include_zeros == 0) && (value[field_ctr] > 0))) {
      field_ctr++;
      if (field_ctr >= max_fields)
        break;
    }
  }
  return field_ctr;
}


x86 assembly (clang, -O0):
<calc_piechart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x870,%rsp
mov    %r8b,%al
mov    0x38(%rbp),%r8d
mov    0x30(%rbp),%r8d
mov    0x28(%rbp),%r8
mov    0x20(%rbp),%r8
mov    0x18(%rbp),%r8
mov    0x10(%rbp),%r8d
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    %r9,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x854(%rbp)
mov    0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x858(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x858(%rbp),%eax
cmp    %ecx,%eax
jge    1485 <calc_piechart+0x335>
mov    -0x10(%rbp),%rdi
mov    -0x3c(%rbp),%ecx
lea    -0x450(%rbp),%r8
lea    -0x850(%rbp),%r9
mov    $0x2c,%esi
mov    $0x7c,%edx
call   1070 <parse_search_string@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x450(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x28(%rbp),%r8
lea    -0x30(%rbp),%r9
lea    -0x38(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <get_totals@plt>
cmpl   $0x0,0x10(%rbp)
je     124a <calc_piechart+0xfa>
movsd  -0x38(%rbp),%xmm0
mov    0x20(%rbp),%rax
movslq -0x854(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    125f <calc_piechart+0x10f>
movsd  -0x30(%rbp),%xmm0
mov    0x20(%rbp),%rax
movslq -0x854(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x20(%rbp),%rax
movslq -0x854(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x28(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    0x18(%rbp),%rax
movslq -0x854(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    0x18(%rbp),%rax
movslq -0x854(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movb   $0x0,(%rax)
movsbl -0x850(%rbp),%eax
cmp    $0x0,%eax
je     1330 <calc_piechart+0x1e0>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x85c(%rbp)
lea    -0x850(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x85c(%rbp),%eax
cmp    %ecx,%eax
jge    1314 <calc_piechart+0x1c4>
movslq -0x40(%rbp),%rax
mov    -0x850(%rbp,%rax,1),%dl
mov    0x18(%rbp),%rax
movslq -0x854(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    12c0 <calc_piechart+0x170>
mov    0x18(%rbp),%rax
movslq -0x854(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x40(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    13e2 <calc_piechart+0x292>
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x860(%rbp)
lea    -0x450(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x860(%rbp),%eax
cmp    %ecx,%eax
jge    13cb <calc_piechart+0x27b>
movslq -0x40(%rbp),%rax
movsbl -0x450(%rbp,%rax,1),%eax
ff
cmp    $0x2a,%eax
je     13b8 <calc_piechart+0x268>
movslq -0x40(%rbp),%rax
movsbl -0x450(%rbp,%rax,1),%eax
ff
cmp    $0x25,%eax
je     13b8 <calc_piechart+0x268>
movslq -0x40(%rbp),%rax
mov    -0x450(%rbp,%rax,1),%dl
mov    0x18(%rbp),%rax
movslq -0x854(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x44(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x44(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    13bd <calc_piechart+0x26d>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    133e <calc_piechart+0x1ee>
mov    0x18(%rbp),%rax
movslq -0x854(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x44(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    0x18(%rbp),%rax
movslq -0x854(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1427 <calc_piechart+0x2d7>
mov    0x18(%rbp),%rax
movslq -0x854(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    0x18(%rbp),%rax
movslq -0x854(%rbp),%rdx
mov    (%rax,%rdx,8),%rax
mov    %cl,(%rax)
cmpl   $0x0,0x38(%rbp)
jne    1458 <calc_piechart+0x308>
cmpl   $0x0,0x38(%rbp)
jne    1480 <calc_piechart+0x330>
mov    0x20(%rbp),%rax
movslq -0x854(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1480 <calc_piechart+0x330>
mov    -0x854(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x854(%rbp)
mov    -0x854(%rbp),%eax
cmp    0x30(%rbp),%eax
jl     147b <calc_piechart+0x32b>
jmp    1485 <calc_piechart+0x335>
jmp    1480 <calc_piechart+0x330>
jmp    11b7 <calc_piechart+0x67>
mov    -0x854(%rbp),%eax
add    $0x870,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_piechart>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x858,%rsp
mov    %r9,%r14
mov    %ecx,%ebp
mov    %edx,0x1c(%rsp)
mov    %rsi,%rbx
mov    %rdi,0x38(%rsp)
mov    0x8a8(%rsp),%rax
movq   $0x0,0x48(%rsp)
movq   $0x0,0x40(%rsp)
movq   $0x0,(%rax)
mov    %rsi,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1390 <calc_piechart+0x240>
mov    0x898(%rsp),%r12
mov    %ebp,0x18(%rsp)
xor    %ebp,%ebp
mov    %r14,0x30(%rsp)
lea    0x450(%rsp),%r15
xor    %r14d,%r14d
mov    %rbx,0x20(%rsp)
jmp    11f6 <calc_piechart+0xa6>
nopl   0x0(%rax,%rax,1)
mov    0x28(%rsp),%rbp
add    $0x1,%ebp
cmp    0x8b0(%rsp),%ebp
jge    1392 <calc_piechart+0x242>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    %eax,%r14d
jge    1392 <calc_piechart+0x242>
mov    %rbx,%rdi
mov    $0x2c,%esi
mov    $0x7c,%edx
mov    %r14d,%ecx
lea    0x50(%rsp),%r14
mov    %r14,%r8
mov    %r15,%r9
call   1070 <parse_search_string@plt>
mov    %eax,0x14(%rsp)
lea    0x40(%rsp),%r13
mov    %r13,(%rsp)
mov    0x38(%rsp),%rdi
mov    %r14,%rsi
mov    0x1c(%rsp),%edx
mov    0x18(%rsp),%ecx
mov    0x30(%rsp),%r8
lea    0x48(%rsp),%rbx
mov    %rbx,%r9
call   1050 <get_totals@plt>
cmpl   $0x0,0x890(%rsp)
cmove  %rbx,%r13
movsd  0x0(%r13),%xmm0
mov    %rbp,0x28(%rsp)
movslq %ebp,%rbp
mov    0x8a0(%rsp),%rax
movsd  %xmm0,(%rax,%rbp,8)
mov    0x8a8(%rsp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,(%r12,%rbp,8)
movb   $0x0,(%rax)
cmpb   $0x0,0x450(%rsp)
je     12e0 <calc_piechart+0x190>
mov    %r15,%rdi
call   1040 <strlen@plt>
xor    %ebx,%ebx
test   %eax,%eax
jle    12d2 <calc_piechart+0x182>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x450(%rsp,%rbx,1),%eax
mov    (%r12,%rbp,8),%rcx
mov    %al,(%rcx,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     12b0 <calc_piechart+0x160>
mov    %ebx,%eax
add    (%r12,%rbp,8),%rax
mov    0x20(%rsp),%rbx
jmp    133d <calc_piechart+0x1ed>
nop
mov    0x20(%rsp),%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1333 <calc_piechart+0x1e3>
xor    %r14d,%r14d
xor    %r13d,%r13d
jmp    1315 <calc_piechart+0x1c5>
nopl   0x0(%rax)
lea    0x50(%rsp),%rdi
add    $0x1,%r14
call   1040 <strlen@plt>
cltq
cmp    %rax,%r14
jge    1336 <calc_piechart+0x1e6>
movzbl 0x50(%rsp,%r14,1),%eax
cmp    $0x25,%al
je     1300 <calc_piechart+0x1b0>
cmp    $0x2a,%al
je     1300 <calc_piechart+0x1b0>
mov    (%r12,%rbp,8),%rcx
movslq %r13d,%rdx
add    $0x1,%r13d
mov    %al,(%rcx,%rdx,1)
jmp    1300 <calc_piechart+0x1b0>
xor    %r13d,%r13d
movslq %r13d,%rax
add    (%r12,%rbp,8),%rax
mov    0x14(%rsp),%r14d
movb   $0x0,(%rax)
mov    (%r12,%rbp,8),%rax
mov    (%rax),%al
test   %al,%al
je     135d <calc_piechart+0x20d>
movsbl %al,%edi
call   1030 <toupper@plt>
mov    (%r12,%rbp,8),%rcx
mov    %al,(%rcx)
cmpl   $0x0,0x8b8(%rsp)
jne    11d0 <calc_piechart+0x80>
mov    0x8a0(%rsp),%rax
movsd  (%rax,%rbp,8),%xmm0
ucomisd 0xc80(%rip),%xmm0
ja     11d0 <calc_piechart+0x80>
mov    0x28(%rsp),%rbp
jmp    11e5 <calc_piechart+0x95>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x858,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @calc_piechart(i8* %0, i8* %1, i32 %2, i32 %3, i8 signext %4, i8* %5, i32 %6, i8** %7, double* %8, double* %9, i32 %10, i32 %11) {
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i8**
%21 = alloca double*
%22 = alloca double*
%23 = alloca i32
%24 = alloca i32
%25 = alloca double
%26 = alloca double
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca [1024 x i8]
%31 = alloca [1024 x i8]
%32 = alloca i32
store i8* %0, i8** %13
store i8* %1, i8** %14
store i32 %2, i32* %15
store i32 %3, i32* %16
store i8 %4, i8* %17
store i8* %5, i8** %18
store i32 %6, i32* %19
store i8** %7, i8*** %20
store double* %8, double** %21
store double* %9, double** %22
store i32 %10, i32* %23
store i32 %11, i32* %24
store double 0.000000e+00, double* %25
store double 0.000000e+00, double* %26
store i32 0, i32* %27
store i32 0, i32* %32
%33 = load double*, double** %22
store double 0.000000e+00, double* %33
br label %34
34: ; preds = %214, %12
%35 = load i32, i32* %27
%36 = load i8*, i8** %14
%37 = call i32 @strlen(i8* %36)
%38 = icmp slt i32 %35, %37
br i1 %38, label %39, label %215
39: ; preds = %34
%40 = load i8*, i8** %14
%41 = load i32, i32* %27
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %30, i64 0, i64 0
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %31, i64 0, i64 0
%44 = call i32 @parse_search_string(i8* %40, i8 signext 44, i8 signext 124, i32 %41, i8* %42, i8* %43)
store i32 %44, i32* %27
%45 = load i8*, i8** %13
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %30, i64 0, i64 0
%47 = load i32, i32* %15
%48 = load i32, i32* %16
%49 = load i8*, i8** %18
%50 = call i32 @get_totals(i8* %45, i8* %46, i32 %47, i32 %48, i8* %49, double* %25, double* %26)
%51 = load i32, i32* %19
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %59
53: ; preds = %39
%54 = load double, double* %26
%55 = load double*, double** %21
%56 = load i32, i32* %32
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
store double %54, double* %58
br label %65
59: ; preds = %39
%60 = load double, double* %25
%61 = load double*, double** %21
%62 = load i32, i32* %32
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds double, double* %61, i64 %63
store double %60, double* %64
br label %65
65: ; preds = %59, %53
%66 = load double*, double** %21
%67 = load i32, i32* %32
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
%70 = load double, double* %69
%71 = load double*, double** %22
%72 = load double, double* %71
%73 = fadd double %72, %70
store double %73, double* %71
%74 = call i64 @malloc(i32 1024)
%75 = inttoptr i64 %74 to i8*
%76 = load i8**, i8*** %20
%77 = load i32, i32* %32
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8*, i8** %76, i64 %78
store i8* %75, i8** %79
%80 = load i8**, i8*** %20
%81 = load i32, i32* %32
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %80, i64 %82
%84 = load i8*, i8** %83
%85 = getelementptr inbounds i8, i8* %84, i64 0
store i8 0, i8* %85
%86 = getelementptr inbounds [1024 x i8], [1024 x i8]* %31, i64 0, i64 0
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %121
90: ; preds = %65
store i32 0, i32* %28
br label %91
91: ; preds = %109, %90
%92 = load i32, i32* %28
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %31, i64 0, i64 0
%94 = call i32 @strlen(i8* %93)
%95 = icmp slt i32 %92, %94
br i1 %95, label %96, label %112
96: ; preds = %91
%97 = load i32, i32* %28
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [1024 x i8], [1024 x i8]* %31, i64 0, i64 %98
%100 = load i8, i8* %99
%101 = load i8**, i8*** %20
%102 = load i32, i32* %32
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i8*, i8** %101, i64 %103
%105 = load i8*, i8** %104
%106 = load i32, i32* %28
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8, i8* %105, i64 %107
store i8 %100, i8* %108
br label %109
109: ; preds = %96
%110 = load i32, i32* %28
%111 = add nsw i32 %110, 1
store i32 %111, i32* %28
br label %91
112: ; preds = %91
%113 = load i8**, i8*** %20
%114 = load i32, i32* %32
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8*, i8** %113, i64 %115
%117 = load i8*, i8** %116
%118 = load i32, i32* %28
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8, i8* %117, i64 %119
store i8 0, i8* %120
br label %168
121: ; preds = %65
store i32 0, i32* %29
store i32 0, i32* %28
br label %122
122: ; preds = %156, %121
%123 = load i32, i32* %28
%124 = getelementptr inbounds [1024 x i8], [1024 x i8]* %30, i64 0, i64 0
%125 = call i32 @strlen(i8* %124)
%126 = icmp slt i32 %123, %125
br i1 %126, label %127, label %159
127: ; preds = %122
%128 = load i32, i32* %28
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [1024 x i8], [1024 x i8]* %30, i64 0, i64 %129
%131 = load i8, i8* %130
%132 = sext i8 %131 to i32
%133 = icmp ne i32 %132, 42
br i1 %133, label %134, label %155
134: ; preds = %127
%135 = load i32, i32* %28
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [1024 x i8], [1024 x i8]* %30, i64 0, i64 %136
%138 = load i8, i8* %137
%139 = sext i8 %138 to i32
%140 = icmp ne i32 %139, 37
br i1 %140, label %141, label %155
141: ; preds = %134
%142 = load i32, i32* %28
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds [1024 x i8], [1024 x i8]* %30, i64 0, i64 %143
%145 = load i8, i8* %144
%146 = load i8**, i8*** %20
%147 = load i32, i32* %32
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i8*, i8** %146, i64 %148
%150 = load i8*, i8** %149
%151 = load i32, i32* %29
%152 = add nsw i32 %151, 1
store i32 %152, i32* %29
%153 = sext i32 %151 to i64
%154 = getelementptr inbounds i8, i8* %150, i64 %153
store i8 %145, i8* %154
br label %155
155: ; preds = %141, %134, %127
br label %156
156: ; preds = %155
%157 = load i32, i32* %28
%158 = add nsw i32 %157, 1
store i32 %158, i32* %28
br label %122
159: ; preds = %122
%160 = load i8**, i8*** %20
%161 = load i32, i32* %32
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i8*, i8** %160, i64 %162
%164 = load i8*, i8** %163
%165 = load i32, i32* %29
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds i8, i8* %164, i64 %166
store i8 0, i8* %167
br label %168
168: ; preds = %159, %112
%169 = load i8**, i8*** %20
%170 = load i32, i32* %32
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds i8*, i8** %169, i64 %171
%173 = load i8*, i8** %172
%174 = getelementptr inbounds i8, i8* %173, i64 0
%175 = load i8, i8* %174
%176 = sext i8 %175 to i32
%177 = icmp ne i32 %176, 0
br i1 %177, label %178, label %193
178: ; preds = %168
%179 = load i8**, i8*** %20
%180 = load i32, i32* %32
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds i8*, i8** %179, i64 %181
%183 = load i8*, i8** %182
%184 = getelementptr inbounds i8, i8* %183, i64 0
%185 = load i8, i8* %184
%186 = call signext i8 @toupper(i8 signext %185)
%187 = load i8**, i8*** %20
%188 = load i32, i32* %32
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds i8*, i8** %187, i64 %189
%191 = load i8*, i8** %190
%192 = getelementptr inbounds i8, i8* %191, i64 0
store i8 %186, i8* %192
br label %193
193: ; preds = %178, %168
%194 = load i32, i32* %24
%195 = icmp ne i32 %194, 0
br i1 %195, label %206, label %196
196: ; preds = %193
%197 = load i32, i32* %24
%198 = icmp eq i32 %197, 0
br i1 %198, label %199, label %214
199: ; preds = %196
%200 = load double*, double** %21
%201 = load i32, i32* %32
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds double, double* %200, i64 %202
%204 = load double, double* %203
%205 = fcmp ogt double %204, 0.000000e+00
br i1 %205, label %206, label %214
206: ; preds = %199, %193
%207 = load i32, i32* %32
%208 = add nsw i32 %207, 1
store i32 %208, i32* %32
%209 = load i32, i32* %32
%210 = load i32, i32* %23
%211 = icmp sge i32 %209, %210
br i1 %211, label %212, label %213
212: ; preds = %206
br label %215
213: ; preds = %206
br label %214
214: ; preds = %213, %199, %196
br label %34
215: ; preds = %212, %34
%216 = load i32, i32* %32
ret i32 %216
}

LLVM IR (-O2):
define i32 @calc_piechart(i8* %0, i8* %1, i32 %2, i32 %3, i8 signext %4, i8* %5, i32 %6, i8** nocapture %7, double* nocapture %8, double* nocapture %9, i32 %10, i32 %11) {
%13 = alloca double
%14 = alloca double
%15 = alloca [1024 x i8]
%16 = alloca [1024 x i8]
%17 = bitcast double* %13 to i8*
store double 0.000000e+00, double* %13
%18 = bitcast double* %14 to i8*
store double 0.000000e+00, double* %14
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
store double 0.000000e+00, double* %9
%21 = call i32 @strlen(i8* %1)
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %105
23: ; preds = %12
%24 = icmp eq i32 %6, 0
%25 = icmp eq i32 %11, 0
br label %26
26: ; preds = %23, %101
%27 = phi i32 [ 0, %23 ], [ %102, %101 ]
%28 = phi i32 [ 0, %23 ], [ %29, %101 ]
%29 = call i32 @parse_search_string(i8* %1, i8 signext 44, i8 signext 124, i32 %28, i8* %19, i8* %20)
%30 = call i32 @get_totals(i8* %0, i8* %19, i32 %2, i32 %3, i8* %5, double* %13, double* %14)
%31 = load double, double* %13
%32 = load double, double* %14
%33 = select i1 %24, double %31, double %32
%34 = sext i32 %27 to i64
%35 = getelementptr inbounds double, double* %8, i64 %34
store double %33, double* %35
%36 = getelementptr inbounds double, double* %8, i64 %34
%37 = load double, double* %9
%38 = fadd double %33, %37
store double %38, double* %9
%39 = call i64 @malloc(i32 1024)
%40 = inttoptr i64 %39 to i8*
%41 = getelementptr inbounds i8*, i8** %7, i64 %34
store i8* %40, i8** %41
store i8 0, i8* %40
%42 = load i8, i8* %20
%43 = icmp eq i8 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %26
%45 = call i32 @strlen(i8* %20)
%46 = icmp sgt i32 %45, 0
br i1 %46, label %50, label %60
47: ; preds = %26
%48 = call i32 @strlen(i8* %19)
%49 = icmp sgt i32 %48, 0
br i1 %49, label %65, label %81
50: ; preds = %44, %50
%51 = phi i64 [ %56, %50 ], [ 0, %44 ]
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = load i8*, i8** %41
%55 = getelementptr inbounds i8, i8* %54, i64 %51
store i8 %53, i8* %55
%56 = add nuw nsw i64 %51, 1
%57 = call i32 @strlen(i8* %20)
%58 = sext i32 %57 to i64
%59 = icmp slt i64 %56, %58
br i1 %59, label %50, label %60
60: ; preds = %50, %44
%61 = phi i64 [ 0, %44 ], [ %56, %50 ]
%62 = load i8*, i8** %41
%63 = and i64 %61, 4294967295
%64 = getelementptr inbounds i8, i8* %62, i64 %63
br label %86
65: ; preds = %47, %75
%66 = phi i64 [ %77, %75 ], [ 0, %47 ]
%67 = phi i32 [ %76, %75 ], [ 0, %47 ]
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 %66
%69 = load i8, i8* %68
switch i8 %69, label %70 [
i8 42, label %75
i8 37, label %75
]
70: ; preds = %65
%71 = load i8*, i8** %41
%72 = add nsw i32 %67, 1
%73 = sext i32 %67 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
store i8 %69, i8* %74
br label %75
75: ; preds = %65, %65, %70
%76 = phi i32 [ %72, %70 ], [ %67, %65 ], [ %67, %65 ]
%77 = add nuw nsw i64 %66, 1
%78 = call i32 @strlen(i8* %19)
%79 = sext i32 %78 to i64
%80 = icmp slt i64 %77, %79
br i1 %80, label %65, label %81
81: ; preds = %75, %47
%82 = phi i32 [ 0, %47 ], [ %76, %75 ]
%83 = load i8*, i8** %41
%84 = sext i32 %82 to i64
%85 = getelementptr inbounds i8, i8* %83, i64 %84
br label %86
86: ; preds = %81, %60
%87 = phi i8* [ %85, %81 ], [ %64, %60 ]
store i8 0, i8* %87
%88 = load i8*, i8** %41
%89 = load i8, i8* %88
%90 = icmp eq i8 %89, 0
br i1 %90, label %94, label %91
91: ; preds = %86
%92 = call signext i8 @toupper(i8 signext %89)
%93 = load i8*, i8** %41
store i8 %92, i8* %93
br label %94
94: ; preds = %91, %86
br i1 %25, label %95, label %98
95: ; preds = %94
%96 = load double, double* %36
%97 = fcmp ogt double %96, 0.000000e+00
br i1 %97, label %98, label %101
98: ; preds = %95, %94
%99 = add nsw i32 %27, 1
%100 = icmp slt i32 %99, %10
br i1 %100, label %101, label %105
101: ; preds = %98, %95
%102 = phi i32 [ %99, %98 ], [ %27, %95 ]
%103 = call i32 @strlen(i8* %1)
%104 = icmp slt i32 %29, %103
br i1 %104, label %26, label %105
105: ; preds = %101, %98, %12
%106 = phi i32 [ 0, %12 ], [ %99, %98 ], [ %102, %101 ]
ret i32 %106
}