#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 strtol(char *, char **, int);
int chop_input(char *buf, int *values, int *code) {
  char *p, *p2;
  int i, v;
  p = buf;
  for (i = 0; i <= 6; i++) {
    v = strtol(p, &p2, 16);
    values[i] = v;
    p = p2;
  }
  if (*p != 0) {
    v = strtol(p, &p2, 16);
    *code = v;
  } else {
    *code = 0;
  }
}


x86 assembly (clang, -O0):
<chop_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x6,-0x34(%rbp)
jg     1176 <chop_input+0x66>
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1133 <chop_input+0x23>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a9 <chop_input+0x99>
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    11b3 <chop_input+0xa3>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chop_input>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0x8(%rsp),%r15
mov    %r15,%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,(%rbx)
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,0x4(%rbx)
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,0x8(%rbx)
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,0xc(%rbx)
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,0x10(%rbx)
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,0x14(%rbx)
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %eax,0x18(%rbx)
mov    0x8(%rsp),%rdi
cmpb   $0x0,(%rdi)
je     11cc <chop_input+0xbc>
lea    0x8(%rsp),%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
jmp    11ce <chop_input+0xbe>
xor    %eax,%eax
mov    %eax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @chop_input(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call i32 @strtol(i8* %0, i8** %4, i32 16)
store i32 %6, i32* %1
%7 = load i8*, i8** %4
%8 = call i32 @strtol(i8* %7, i8** %4, i32 16)
%9 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %8, i32* %9
%10 = load i8*, i8** %4
%11 = call i32 @strtol(i8* %10, i8** %4, i32 16)
%12 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %11, i32* %12
%13 = load i8*, i8** %4
%14 = call i32 @strtol(i8* %13, i8** %4, i32 16)
%15 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %14, i32* %15
%16 = load i8*, i8** %4
%17 = call i32 @strtol(i8* %16, i8** %4, i32 16)
%18 = getelementptr inbounds i32, i32* %1, i64 4
store i32 %17, i32* %18
%19 = load i8*, i8** %4
%20 = call i32 @strtol(i8* %19, i8** %4, i32 16)
%21 = getelementptr inbounds i32, i32* %1, i64 5
store i32 %20, i32* %21
%22 = load i8*, i8** %4
%23 = call i32 @strtol(i8* %22, i8** %4, i32 16)
%24 = getelementptr inbounds i32, i32* %1, i64 6
store i32 %23, i32* %24
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %3
%29 = call i32 @strtol(i8* %25, i8** %4, i32 16)
br label %30
30: ; preds = %3, %28
%31 = phi i32 [ %29, %28 ], [ 0, %3 ]
store i32 %31, i32* %2
ret i32 undef
}