#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 */
struct sip_msg {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int sip_msg_invite_parse(struct sip_msg *, char *);
int sip_parse_response(struct sip_msg *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strsep(char **, char *);
int sip_hdrline_parse(struct sip_msg *sm, char *line) {
  char *tag;
  tag = strsep(&line, " ");
  if (strcmp(tag, "SIP/2.0") == 0)
    return sip_parse_response(sm, line);
  else if (strcmp(tag, "INVITE") == 0)
    return sip_msg_invite_parse(sm, line);
  fprintf(stderr, "sip_parse_header: %s not yet supported\n", tag);
  return -1;
}


x86 assembly (clang, -O0):
<sip_hdrline_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1050 <strsep@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a3 <sip_hdrline_parse+0x53>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <sip_parse_response@plt>
mov    %eax,-0x4(%rbp)
jmp    11f7 <sip_hdrline_parse+0xa7>
mov    -0x20(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11d2 <sip_hdrline_parse+0x82>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <sip_msg_invite_parse@plt>
mov    %eax,-0x4(%rbp)
jmp    11f7 <sip_hdrline_parse+0xa7>
jmp    11d7 <sip_hdrline_parse+0x87>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe26(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sip_hdrline_parse>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,(%rsp)
lea    0xe9e(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strsep@plt>
mov    %rax,%rbx
lea    0xe8e(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b4 <sip_hdrline_parse+0x64>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c2 <sip_hdrline_parse+0x72>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    11ce <sip_hdrline_parse+0x7e>
mov    (%rsp),%rsi
mov    %r14,%rdi
call   1070 <sip_parse_response@plt>
jmp    11ce <sip_hdrline_parse+0x7e>
mov    (%rsp),%rsi
mov    %r14,%rdi
call   1060 <sip_msg_invite_parse@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sip_msg = type { i32 }
@.str = [2 x i8] c" \00"
@.str.1 = [8 x i8] c"SIP/2.0\00"
@.str.2 = [7 x i8] c"INVITE\00"
@stderr = global i32 0
@.str.3 = [40 x i8] c"sip_parse_header: %s not yet supported\0A\00"
define i32 @sip_hdrline_parse(%struct.sip_msg* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.sip_msg*
%5 = alloca i8*
%6 = alloca i8*
store %struct.sip_msg* %0, %struct.sip_msg** %4
store i8* %1, i8** %5
%7 = call i8* @strsep(i8** %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %6
%8 = load i8*, i8** %6
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load %struct.sip_msg*, %struct.sip_msg** %4
%13 = load i8*, i8** %5
%14 = call i32 @sip_parse_response(%struct.sip_msg* %12, i8* %13)
store i32 %14, i32* %3
br label %28
15: ; preds = %2
%16 = load i8*, i8** %6
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load %struct.sip_msg*, %struct.sip_msg** %4
%21 = load i8*, i8** %5
%22 = call i32 @sip_msg_invite_parse(%struct.sip_msg* %20, i8* %21)
store i32 %22, i32* %3
br label %28
23: ; preds = %15
br label %24
24: ; preds = %23
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %6
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %26)
store i32 -1, i32* %3
br label %28
28: ; preds = %24, %19, %11
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.sip_msg = type { i32 }
@.str = [2 x i8] c" \00"
@.str.1 = [8 x i8] c"SIP/2.0\00"
@.str.2 = [7 x i8] c"INVITE\00"
@stderr = global i32 0
@.str.3 = [40 x i8] c"sip_parse_header: %s not yet supported\0A\00"
define i32 @sip_hdrline_parse(%struct.sip_msg* %0, i8* %1) {
%3 = alloca i8*
store i8* %1, i8** %3
%4 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = call i32 @sip_parse_response(%struct.sip_msg* %0, i8* %8)
br label %19
10: ; preds = %2
%11 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i8*, i8** %3
%15 = call i32 @sip_msg_invite_parse(%struct.sip_msg* %0, i8* %14)
br label %19
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %19
19: ; preds = %16, %13, %7
%20 = phi i32 [ %9, %7 ], [ %15, %13 ], [ -1, %16 ]
ret i32 %20
}