#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 tm {
  int dummy;
};

/* Variables and functions */
char *match_b_record(char const *, struct tm *);
char *match_hfdte_record(char const *, struct tm *);
int igc_tm_update(struct tm *tm, const char *p) {
  switch (p[0]) {
  case 'B':
    p = match_b_record(p, tm);
    break;
  case 'H':
    p = match_hfdte_record(p, tm);
    break;
  default:
    p = 0;
    break;
  }
  return !!p;
}


x86 assembly (clang, -O0):
<igc_tm_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x42,%eax
je     1159 <igc_tm_update+0x39>
jmp    1148 <igc_tm_update+0x28>
mov    -0x14(%rbp),%eax
sub    $0x48,%eax
je     116f <igc_tm_update+0x4f>
jmp    1185 <igc_tm_update+0x65>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <match_b_record@plt>
mov    %rax,-0x10(%rbp)
jmp    118d <igc_tm_update+0x6d>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <match_hfdte_record@plt>
mov    %rax,-0x10(%rbp)
jmp    118d <igc_tm_update+0x6d>
movq   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<igc_tm_update>:
push   %rax
mov    %rdi,%rax
movsbl (%rsi),%ecx
cmp    $0x48,%ecx
je     113e <igc_tm_update+0x1e>
cmp    $0x42,%ecx
jne    114b <igc_tm_update+0x2b>
mov    %rsi,%rdi
mov    %rax,%rsi
call   1040 <match_b_record@plt>
jmp    114d <igc_tm_update+0x2d>
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <match_hfdte_record@plt>
jmp    114d <igc_tm_update+0x2d>
xor    %eax,%eax
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define i32 @igc_tm_update(%struct.tm* %0, i8* %1) {
%3 = alloca %struct.tm*
%4 = alloca i8*
store %struct.tm* %0, %struct.tm** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %17 [
i32 66, label %9
i32 72, label %13
]
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = load %struct.tm*, %struct.tm** %3
%12 = call i8* @match_b_record(i8* %10, %struct.tm* %11)
store i8* %12, i8** %4
br label %18
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = load %struct.tm*, %struct.tm** %3
%16 = call i8* @match_hfdte_record(i8* %14, %struct.tm* %15)
store i8* %16, i8** %4
br label %18
17: ; preds = %2
store i8* null, i8** %4
br label %18
18: ; preds = %17, %13, %9
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
%21 = xor i1 %20, true
%22 = xor i1 %21, true
%23 = zext i1 %22 to i32
ret i32 %23
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i32 @igc_tm_update(%struct.tm* %0, i8* %1) {
%3 = load i8, i8* %1
%4 = sext i8 %3 to i32
switch i32 %4, label %9 [
i32 66, label %5
i32 72, label %7
]
5: ; preds = %2
%6 = tail call i8* @match_b_record(i8* %1, %struct.tm* %0)
br label %9
7: ; preds = %2
%8 = tail call i8* @match_hfdte_record(i8* %1, %struct.tm* %0)
br label %9
9: ; preds = %2, %7, %5
%10 = phi i8* [ %8, %7 ], [ %6, %5 ], [ null, %2 ]
%11 = icmp ne i8* %10, null
%12 = zext i1 %11 to i32
ret i32 %12
}