#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 *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
char *strdup(char *);
int strlen(char *);
void get_coord(char *str, int *x, int *y) {
  int i;
  char *cur_arg = 0;
  *x = *y = 0;
  for (i = 0; i < strlen(str); i++)
    if (str[i] == ',')
      break;
  if (i == strlen(str)) {
    fprintf(stderr, "get_coord: no comma found in pair of coordinates '%s'\n",
            str);
    return;
  }
  cur_arg = str + i + 1;
  if (cur_arg[0] == 0)
    fprintf(stderr, "get_coord: warning: y-coordinate is empty (maybe you left "
                    "a space between x and comma?)\n");
  *y = atoi(cur_arg);
  cur_arg = strdup(str);
  cur_arg[i] = 0;
  *x = atoi(cur_arg);
  {
    if (cur_arg)
      free(cur_arg);
    cur_arg = 0;
  };
}


x86 assembly (clang, -O0):
<get_coord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    11d0 <get_coord+0x80>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2c,%eax
jne    11bd <get_coord+0x6d>
jmp    11d0 <get_coord+0x80>
jmp    11c2 <get_coord+0x72>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1187 <get_coord+0x37>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jne    120c <get_coord+0xbc>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    129d <get_coord+0x14d>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1246 <get_coord+0xf6>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xdf8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x28(%rbp)
je     1295 <get_coord+0x145>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_coord>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r13
movl   $0x0,(%rdx)
movl   $0x0,(%rsi)
call   1040 <strlen@plt>
xor    %ebx,%ebx
test   %eax,%eax
jle    119b <get_coord+0x4b>
nopl   0x0(%rax,%rax,1)
cmpb   $0x2c,0x0(%r13,%rbx,1)
je     119b <get_coord+0x4b>
add    $0x1,%rbx
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1180 <get_coord+0x30>
mov    %r13,%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebx
jne    11cf <get_coord+0x7f>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fprintf@plt>
mov    %ebx,%ebp
lea    0x1(,%rbp,1),%r12
add    %r13,%r12
cmpb   $0x0,0x1(%r13,%rbp,1)
jne    11fb <get_coord+0xab>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r12,%rdi
call   1060 <atoi@plt>
mov    %eax,(%r15)
mov    %r13,%rdi
call   1070 <strdup@plt>
mov    %rax,%rbx
movb   $0x0,(%rax,%rbp,1)
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,(%r14)
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [55 x i8] c"get_coord: no comma found in pair of coordinates '%s'\0A\00"
@.str.1 = [89 x i8] c"get_coord: warning: y-coordinate is empty (maybe you left a space between x and comma?)\0A\00"
define void @get_coord(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i8* null, i8** %8
%9 = load i32*, i32** %6
store i32 0, i32* %9
%10 = load i32*, i32** %5
store i32 0, i32* %10
store i32 0, i32* %7
br label %11
11: ; preds = %26, %3
%12 = load i32, i32* %7
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %29
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 44
br i1 %23, label %24, label %25
24: ; preds = %16
br label %29
25: ; preds = %16
br label %26
26: ; preds = %25
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %11
29: ; preds = %24, %11
%30 = load i32, i32* %7
%31 = load i8*, i8** %4
%32 = call i32 @strlen(i8* %31)
%33 = icmp eq i32 %30, %32
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %4
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %36)
br label %71
38: ; preds = %29
%39 = load i8*, i8** %4
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = getelementptr inbounds i8, i8* %42, i64 1
store i8* %43, i8** %8
%44 = load i8*, i8** %8
%45 = getelementptr inbounds i8, i8* %44, i64 0
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %38
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.1, i64 0, i64 0))
br label %52
52: ; preds = %49, %38
%53 = load i8*, i8** %8
%54 = call i32 @atoi(i8* %53)
%55 = load i32*, i32** %6
store i32 %54, i32* %55
%56 = load i8*, i8** %4
%57 = call i8* @strdup(i8* %56)
store i8* %57, i8** %8
%58 = load i8*, i8** %8
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
store i8 0, i8* %61
%62 = load i8*, i8** %8
%63 = call i32 @atoi(i8* %62)
%64 = load i32*, i32** %5
store i32 %63, i32* %64
%65 = load i8*, i8** %8
%66 = icmp ne i8* %65, null
br i1 %66, label %67, label %70
67: ; preds = %52
%68 = load i8*, i8** %8
%69 = call i32 @free(i8* %68)
br label %70
70: ; preds = %67, %52
store i8* null, i8** %8
br label %71
71: ; preds = %70, %34
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [55 x i8] c"get_coord: no comma found in pair of coordinates '%s'\0A\00"
@.str.1 = [89 x i8] c"get_coord: warning: y-coordinate is empty (maybe you left a space between x and comma?)\0A\00"
define void @get_coord(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
store i32 0, i32* %2
store i32 0, i32* %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %3, %11
%7 = phi i64 [ %12, %11 ], [ 0, %3 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 44
br i1 %10, label %16, label %11
11: ; preds = %6
%12 = add nuw nsw i64 %7, 1
%13 = tail call i32 @strlen(i8* %0)
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %12, %14
br i1 %15, label %6, label %16
16: ; preds = %6, %11
%17 = phi i64 [ %12, %11 ], [ %7, %6 ]
%18 = trunc i64 %17 to i32
br label %19
19: ; preds = %16, %3
%20 = phi i32 [ 0, %3 ], [ %18, %16 ]
%21 = tail call i32 @strlen(i8* %0)
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %41
26: ; preds = %19
%27 = zext i32 %20 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %26, %32
%36 = tail call i32 @atoi(i8* %29)
store i32 %36, i32* %2
%37 = tail call i8* @strdup(i8* %0)
%38 = getelementptr inbounds i8, i8* %37, i64 %27
store i8 0, i8* %38
%39 = tail call i32 @atoi(i8* %37)
store i32 %39, i32* %1
%40 = tail call i32 @free(i8* %37)
br label %41
41: ; preds = %35, %23
ret void
}