#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 const *, char);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int CheckLine(const char *buffer, char *tempCity, int *tempTemp) {
  char *leading = NULL;
  leading = strchr(buffer, ',');
  if (leading == NULL)
    return 1;
  strncpy(tempCity, buffer, leading - buffer);
  *tempTemp = atoi(leading + 1);
  return 0;
}


x86 assembly (clang, -O0):
<CheckLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1175 <CheckLine+0x45>
movl   $0x1,-0x4(%rbp)
jmp    11ab <CheckLine+0x7b>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckLine>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    $0x2c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1176 <CheckLine+0x46>
mov    %rax,%rbx
mov    %ebx,%edx
sub    %r12d,%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <strncpy@plt>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14)
xor    %eax,%eax
jmp    117b <CheckLine+0x4b>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @CheckLine(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i8* null, i8** %8
%9 = load i8*, i8** %5
%10 = call i8* @strchr(i8* %9, i8 signext 44)
store i8* %10, i8** %8
%11 = load i8*, i8** %8
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 1, i32* %4
br label %28
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = load i8*, i8** %5
%17 = load i8*, i8** %8
%18 = load i8*, i8** %5
%19 = ptrtoint i8* %17 to i64
%20 = ptrtoint i8* %18 to i64
%21 = sub i64 %19, %20
%22 = trunc i64 %21 to i32
%23 = call i32 @strncpy(i8* %15, i8* %16, i32 %22)
%24 = load i8*, i8** %8
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = call i32 @atoi(i8* %25)
%27 = load i32*, i32** %7
store i32 %26, i32* %27
store i32 0, i32* %4
br label %28
28: ; preds = %14, %13
%29 = load i32, i32* %4
ret i32 %29
}

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