#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__ atoi(char *);
scalar_t__ calloc(scalar_t__, int);
int /*<<< orphan*/ check_alloc(char *);
char check_col(char *);
int /*<<< orphan*/ free(char *);
int sscanf(char *, char *, char *);
scalar_t__ strlen(char *);
char look_for_column(char *name, unsigned int *col) {
  char *hcol, *hname;
  char vcol = 0;
  int j, in;
  check_alloc(hname = (char *)calloc(strlen(name) + 1, 1));
  check_alloc(hcol = (char *)calloc(strlen(name) + 1, 1));
  j = 0;
  while (*(name + j) != '\0') {
    if (*(name + j) == ',') {
      in = sscanf(name + j + 1, "%s", hcol);
      if (in > 0)
        vcol = check_col(hcol);
      *(name + j) = '\0';
      break;
    }
    *(hname + j) = *(name + j);
    j++;
  }
  *col = (unsigned int)atoi(hcol);
  free(hname);
  free(hcol);
  return vcol;
}


x86 assembly (clang, -O0):
<look_for_column>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x21(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rdi
mov    %rdi,-0x20(%rbp)
call   1090 <check_alloc@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rdi
mov    %rdi,-0x18(%rbp)
call   1090 <check_alloc@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     126e <look_for_column+0xfe>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2c,%eax
jne    124a <look_for_column+0xda>
mov    -0x8(%rbp),%rdi
movslq -0x28(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rdx
lea    0xde5(%rip),%rsi
call   1070 <sscanf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    1239 <look_for_column+0xc9>
mov    -0x18(%rbp),%rdi
call   1050 <check_col@plt>
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    126e <look_for_column+0xfe>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11d7 <look_for_column+0x67>
mov    -0x18(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movsbl -0x21(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<look_for_column>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1090 <check_alloc@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1090 <check_alloc@plt>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx,%rax,1),%ebp
test   %bpl,%bpl
je     121d <look_for_column+0xad>
cmp    $0x2c,%bpl
je     11e9 <look_for_column+0x79>
mov    %bpl,(%r12,%rax,1)
add    $0x1,%rax
jmp    11d0 <look_for_column+0x60>
mov    %eax,%eax
lea    (%rbx,%rax,1),%r13
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
lea    0xe02(%rip),%rsi
mov    %r15,%rdx
call   1070 <sscanf@plt>
test   %eax,%eax
jle    1216 <look_for_column+0xa6>
mov    %r15,%rdi
call   1050 <check_col@plt>
mov    %eax,%ebp
jmp    1218 <look_for_column+0xa8>
xor    %ebp,%ebp
movb   $0x0,0x0(%r13)
mov    %r15,%rdi
call   1080 <atoi@plt>
mov    %eax,(%r14)
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define signext i8 @look_for_column(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
store i8 0, i8* %7
%10 = load i8*, i8** %3
%11 = call i64 @strlen(i8* %10)
%12 = add nsw i64 %11, 1
%13 = call i64 @calloc(i64 %12, i32 1)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %6
%15 = call i32 @check_alloc(i8* %14)
%16 = load i8*, i8** %3
%17 = call i64 @strlen(i8* %16)
%18 = add nsw i64 %17, 1
%19 = call i64 @calloc(i64 %18, i32 1)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %5
%21 = call i32 @check_alloc(i8* %20)
store i32 0, i32* %8
br label %22
22: ; preds = %56, %2
%23 = load i8*, i8** %3
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %68
30: ; preds = %22
%31 = load i8*, i8** %3
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 44
br i1 %37, label %38, label %56
38: ; preds = %30
%39 = load i8*, i8** %3
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = getelementptr inbounds i8, i8* %42, i64 1
%44 = load i8*, i8** %5
%45 = call i32 @sscanf(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %44)
store i32 %45, i32* %9
%46 = load i32, i32* %9
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %38
%49 = load i8*, i8** %5
%50 = call signext i8 @check_col(i8* %49)
store i8 %50, i8* %7
br label %51
51: ; preds = %48, %38
%52 = load i8*, i8** %3
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 0, i8* %55
br label %68
56: ; preds = %30
%57 = load i8*, i8** %3
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
%62 = load i8*, i8** %6
%63 = load i32, i32* %8
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
store i8 %61, i8* %65
%66 = load i32, i32* %8
%67 = add nsw i32 %66, 1
store i32 %67, i32* %8
br label %22
68: ; preds = %51, %22
%69 = load i8*, i8** %5
%70 = call i64 @atoi(i8* %69)
%71 = trunc i64 %70 to i32
%72 = load i32*, i32** %4
store i32 %71, i32* %72
%73 = load i8*, i8** %6
%74 = call i32 @free(i8* %73)
%75 = load i8*, i8** %5
%76 = call i32 @free(i8* %75)
%77 = load i8, i8* %7
ret i8 %77
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define signext i8 @look_for_column(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = add nsw i64 %3, 1
%5 = tail call i64 @calloc(i64 %4, i32 1)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @check_alloc(i8* %6)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%9 = add nsw i64 %8, 1
%10 = tail call i64 @calloc(i64 %9, i32 1)
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 @check_alloc(i8* %11)
br label %13
13: ; preds = %27, %2
%14 = phi i64 [ %29, %27 ], [ 0, %2 ]
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
switch i8 %16, label %27 [
i8 0, label %30
i8 44, label %17
]
17: ; preds = %13
%18 = and i64 %14, 4294967295
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = tail call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = tail call signext i8 @check_col(i8* %11)
br label %25
25: ; preds = %23, %17
%26 = phi i8 [ %24, %23 ], [ 0, %17 ]
store i8 0, i8* %19
br label %30
27: ; preds = %13
%28 = getelementptr inbounds i8, i8* %6, i64 %14
store i8 %16, i8* %28
%29 = add nuw i64 %14, 1
br label %13
30: ; preds = %13, %25
%31 = phi i8 [ %26, %25 ], [ %16, %13 ]
%32 = tail call i64 @atoi(i8* %11)
%33 = trunc i64 %32 to i32
store i32 %33, i32* %1
%34 = tail call i32 @free(i8* %6)
%35 = tail call i32 @free(i8* %11)
ret i8 %31
}