#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 atoi(char *);
scalar_t__ piece(char *, char, char *, int);
void populate_trim_array(int *trim_array, char *piece_offset_comma_list) {
  char piece_buffer[256];
  int p;
  for (p = 0; piece(piece_buffer, ',', piece_offset_comma_list, p); p++) {
    trim_array[p] = atoi(piece_buffer);
  }
}


x86 assembly (clang, -O0):
<populate_trim_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x114(%rbp),%ecx
mov    $0x2c,%esi
call   1040 <piece@plt>
cmp    $0x0,%rax
je     1192 <populate_trim_array+0x72>
lea    -0x110(%rbp),%rdi
call   1030 <atoi@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x114(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    113d <populate_trim_array+0x1d>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<populate_trim_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsp,%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1040 <piece@plt>
test   %rax,%rax
je     1177 <populate_trim_array+0x57>
xor    %ebx,%ebx
mov    %rsp,%r12
mov    %r12,%rdi
call   1030 <atoi@plt>
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
mov    %r12,%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1040 <piece@plt>
test   %rax,%rax
jne    1150 <populate_trim_array+0x30>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @populate_trim_array(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca [256 x i8]
%6 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32 0, i32* %6
br label %7
7: ; preds = %20, %2
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%9 = load i8*, i8** %4
%10 = load i32, i32* %6
%11 = call i64 @piece(i8* %8, i8 signext 44, i8* %9, i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %7
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%15 = call i32 @atoi(i8* %14)
%16 = load i32*, i32** %3
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
store i32 %15, i32* %19
br label %20
20: ; preds = %13
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %7
23: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @populate_trim_array(i32* nocapture writeonly %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i64 @piece(i8* %4, i8 signext 44, i8* %1, i32 0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %11, %7 ], [ 0, %2 ]
%9 = call i32 @atoi(i8* %4)
%10 = getelementptr inbounds i32, i32* %0, i64 %8
store i32 %9, i32* %10
%11 = add nuw i64 %8, 1
%12 = trunc i64 %11 to i32
%13 = call i64 @piece(i8* %4, i8 signext 44, i8* %1, i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %7
15: ; preds = %7, %2
ret void
}