#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 */
typedef void katcp_tag;
struct katcp_dispatch {
  int dummy;
};

/* Variables and functions */
int atoi(char *);
void *create_tag_katcp(char *, int);
void *parse_tag_katcp(struct katcp_dispatch *d, char **str) {
  struct katcp_tag *t;
  int level;
  level = 0;
  if (str == NULL || str[0] == NULL || str[1] == NULL)
    return NULL;
  level = atoi(str[1]);
  t = create_tag_katcp(str[0], level);
  return t;
}


x86 assembly (clang, -O0):
<parse_tag_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     115f <parse_tag_katcp+0x3f>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     115f <parse_tag_katcp+0x3f>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    116c <parse_tag_katcp+0x4c>
movq   $0x0,-0x8(%rbp)
jmp    1197 <parse_tag_katcp+0x77>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x24(%rbp),%esi
call   1030 <create_tag_katcp@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_tag_katcp>:
push   %rbx
test   %rsi,%rsi
je     1147 <parse_tag_katcp+0x27>
mov    (%rsi),%rbx
test   %rbx,%rbx
je     1147 <parse_tag_katcp+0x27>
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     1147 <parse_tag_katcp+0x27>
call   1040 <atoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
pop    %rbx
jmp    1030 <create_tag_katcp@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.katcp_dispatch = type { i32 }
%struct.katcp_tag = type opaque
define i8* @parse_tag_katcp(%struct.katcp_dispatch* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca %struct.katcp_dispatch*
%5 = alloca i8**
%6 = alloca %struct.katcp_tag*
%7 = alloca i32
store %struct.katcp_dispatch* %0, %struct.katcp_dispatch** %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%8 = load i8**, i8*** %5
%9 = icmp eq i8** %8, null
br i1 %9, label %20, label %10
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = icmp eq i8* %13, null
br i1 %14, label %20, label %15
15: ; preds = %10
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %15, %10, %2
store i8* null, i8** %3
br label %34
21: ; preds = %15
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %7
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = load i32, i32* %7
%30 = call i8* @create_tag_katcp(i8* %28, i32 %29)
%31 = bitcast i8* %30 to %struct.katcp_tag*
store %struct.katcp_tag* %31, %struct.katcp_tag** %6
%32 = load %struct.katcp_tag*, %struct.katcp_tag** %6
%33 = bitcast %struct.katcp_tag* %32 to i8*
store i8* %33, i8** %3
br label %34
34: ; preds = %21, %20
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
%struct.katcp_dispatch = type { i32 }
define i8* @parse_tag_katcp(%struct.katcp_dispatch* nocapture readnone %0, i8** %1) {
%3 = icmp eq i8** %1, null
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = icmp eq i8* %5, null
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = icmp eq i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = tail call i32 @atoi(i8* %9)
%13 = tail call i8* @create_tag_katcp(i8* %5, i32 %12)
br label %14
14: ; preds = %2, %4, %7, %11
%15 = phi i8* [ %13, %11 ], [ null, %7 ], [ null, %4 ], [ null, %2 ]
ret i8* %15
}