#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 *);
char *strchr(char *, char);
void itemdb_split_atoi(char *str, int *melee, int *magic) {
  int i, val[2];
  for (i = 0; i < 2; i++) {
    if (str) {
      val[i] = atoi(str);
      str = strchr(str, ':');
      if (str)
        *str++ = 0;
    } else {
      val[i] = 0;
    }
  }
  *melee = val[0];
  *magic = val[1];
  return;
}


x86 assembly (clang, -O0):
<itemdb_split_atoi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    11b6 <itemdb_split_atoi+0x96>
cmpq   $0x0,-0x8(%rbp)
je     1197 <itemdb_split_atoi+0x77>
mov    -0x8(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
movslq -0x1c(%rbp),%rax
mov    %ecx,-0x24(%rbp,%rax,4)
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1192 <itemdb_split_atoi+0x72>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
jmp    11a3 <itemdb_split_atoi+0x83>
movslq -0x1c(%rbp),%rax
movl   $0x0,-0x24(%rbp,%rax,4)
jmp    11a8 <itemdb_split_atoi+0x88>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <itemdb_split_atoi+0x1b>
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<itemdb_split_atoi>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
xor    %ebp,%ebp
test   %rdi,%rdi
je     117d <itemdb_split_atoi+0x5d>
mov    %rdi,%rbx
call   1040 <atoi@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1180 <itemdb_split_atoi+0x60>
mov    %rax,%rbx
add    $0x1,%rbx
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1040 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1180 <itemdb_split_atoi+0x60>
movb   $0x0,(%rax)
jmp    1180 <itemdb_split_atoi+0x60>
xor    %r12d,%r12d
mov    %r12d,(%r15)
mov    %ebp,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @itemdb_split_atoi(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [2 x i32]
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %7
br label %9
9: ; preds = %34, %3
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %37
12: ; preds = %9
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load i8*, i8** %4
%17 = call i32 @atoi(i8* %16)
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 %19
store i32 %17, i32* %20
%21 = load i8*, i8** %4
%22 = call i8* @strchr(i8* %21, i8 signext 58)
store i8* %22, i8** %4
%23 = load i8*, i8** %4
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %15
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
store i8 0, i8* %26
br label %28
28: ; preds = %25, %15
br label %33
29: ; preds = %12
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 %31
store i32 0, i32* %32
br label %33
33: ; preds = %29, %28
br label %34
34: ; preds = %33
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %9
37: ; preds = %9
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%39 = load i32, i32* %38
%40 = load i32*, i32** %5
store i32 %39, i32* %40
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%42 = load i32, i32* %41
%43 = load i32*, i32** %6
store i32 %42, i32* %43
ret void
}

LLVM IR (-O2):
define void @itemdb_split_atoi(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %15, label %5
5: ; preds = %3
%6 = tail call i32 @atoi(i8* %0)
%7 = tail call i8* @strchr(i8* %0, i8 signext 58)
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %7, i64 1
store i8 0, i8* %7
%11 = tail call i32 @atoi(i8* %10)
%12 = tail call i8* @strchr(i8* %10, i8 signext 58)
%13 = icmp eq i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %9
store i8 0, i8* %12
br label %15
15: ; preds = %3, %5, %14, %9
%16 = phi i32 [ %6, %9 ], [ %6, %14 ], [ 0, %3 ], [ %6, %5 ]
%17 = phi i32 [ %11, %9 ], [ %11, %14 ], [ 0, %3 ], [ 0, %5 ]
store i32 %16, i32* %1
store i32 %17, i32* %2
ret void
}