#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 */
unsigned long strtoul(char *, char **, int);
unsigned long _getport(char *line, char **here) {
  unsigned long port;
  char *p;
  p = line;
  port = strtoul(p, &p, 10);
  if (*p != ',')
    return (0);
  p++;
  port = (port << 8) + strtoul(p, &p, 10);
  if (here != NULL)
    *here = p;
  return (port);
}


x86 assembly (clang, -O0):
<_getport>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
je     115b <_getport+0x4b>
movq   $0x0,-0x8(%rbp)
jmp    11b1 <_getport+0xa1>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a9 <_getport+0x99>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_getport>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,(%rsp)
mov    %rsp,%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    (%rsp),%rdi
cmpb   $0x2c,(%rdi)
jne    115e <_getport+0x4e>
mov    %rax,%rbx
add    $0x1,%rdi
mov    %rdi,(%rsp)
shl    $0x8,%rbx
mov    %rsp,%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
add    %rbx,%rax
test   %r14,%r14
je     1160 <_getport+0x50>
mov    (%rsp),%rcx
mov    %rcx,(%r14)
jmp    1160 <_getport+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @_getport(i8* %0, i8** %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
%8 = load i8*, i8** %4
store i8* %8, i8** %7
%9 = load i8*, i8** %7
%10 = call i64 @strtoul(i8* %9, i8** %7, i32 10)
store i64 %10, i64* %6
%11 = load i8*, i8** %7
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 44
br i1 %14, label %15, label %16
15: ; preds = %2
store i64 0, i64* %3
br label %31
16: ; preds = %2
%17 = load i8*, i8** %7
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %7
%19 = load i64, i64* %6
%20 = shl i64 %19, 8
%21 = load i8*, i8** %7
%22 = call i64 @strtoul(i8* %21, i8** %7, i32 10)
%23 = add i64 %20, %22
store i64 %23, i64* %6
%24 = load i8**, i8*** %5
%25 = icmp ne i8** %24, null
br i1 %25, label %26, label %29
26: ; preds = %16
%27 = load i8*, i8** %7
%28 = load i8**, i8*** %5
store i8* %27, i8** %28
br label %29
29: ; preds = %26, %16
%30 = load i64, i64* %6
store i64 %30, i64* %3
br label %31
31: ; preds = %29, %15
%32 = load i64, i64* %3
ret i64 %32
}

LLVM IR (-O2):
define i64 @_getport(i8* %0, i8** writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* %0, i8** %3
%5 = call i64 @strtoul(i8* %0, i8** %3, i32 10)
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 44
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %10, i8** %3
%11 = shl i64 %5, 8
%12 = call i64 @strtoul(i8* %10, i8** %3, i32 10)
%13 = add i64 %12, %11
%14 = icmp eq i8** %1, null
br i1 %14, label %17, label %15
15: ; preds = %9
%16 = load i8*, i8** %3
store i8* %16, i8** %1
br label %17
17: ; preds = %9, %15, %2
%18 = phi i64 [ 0, %2 ], [ %13, %15 ], [ %13, %9 ]
ret i64 %18
}