#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 scan_xml_playlists_section(int, char *);
int scan_xml_preamble_section(int, char *);
int scan_xml_tracks_section(int, char *);
scalar_t__ util_must_exit();
void scan_xml_handler(int action, void *puser, char *info) {
  static int state;
  if (util_must_exit())
    return;
  switch (action) {
  case 0x0:
    state = 0;
    scan_xml_preamble_section(action, info);
    scan_xml_tracks_section(action, info);
    scan_xml_playlists_section(action, info);
    break;
  case 0x2:
  case 0x3:
  case 0x4:
    switch (state) {
    case 0:
      state = scan_xml_preamble_section(action, info);
      break;
    case 1:
      state = scan_xml_tracks_section(action, info);
      break;
    case 2:
      state = scan_xml_playlists_section(action, info);
      break;
    default:
      break;
    }
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<scan_xml_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1050 <util_must_exit@plt>
cmp    $0x0,%rax
je     1169 <scan_xml_handler+0x29>
jmp    124f <scan_xml_handler+0x10f>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     1190 <scan_xml_handler+0x50>
jmp    117c <scan_xml_handler+0x3c>
mov    -0x1c(%rbp),%eax
add    $0xfffffffe,%eax
sub    $0x3,%eax
jb     11c3 <scan_xml_handler+0x83>
jmp    124a <scan_xml_handler+0x10a>
movl   $0x0,0x2eaa(%rip)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <scan_xml_preamble_section@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1060 <scan_xml_tracks_section@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <scan_xml_playlists_section@plt>
jmp    124f <scan_xml_handler+0x10f>
mov    0x2e7b(%rip),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     11fb <scan_xml_handler+0xbb>
jmp    11d9 <scan_xml_handler+0x99>
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
je     1212 <scan_xml_handler+0xd2>
jmp    11ea <scan_xml_handler+0xaa>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
je     1229 <scan_xml_handler+0xe9>
jmp    1240 <scan_xml_handler+0x100>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <scan_xml_preamble_section@plt>
mov    %eax,0x2e37(%rip)
jmp    1245 <scan_xml_handler+0x105>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1060 <scan_xml_tracks_section@plt>
mov    %eax,0x2e20(%rip)
jmp    1245 <scan_xml_handler+0x105>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <scan_xml_playlists_section@plt>
mov    %eax,0x2e09(%rip)
jmp    1245 <scan_xml_handler+0x105>
jmp    1245 <scan_xml_handler+0x105>
jmp    124a <scan_xml_handler+0x10a>
jmp    124f <scan_xml_handler+0x10f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_xml_handler>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <util_must_exit@plt>
test   %rax,%rax
jne    11cc <scan_xml_handler+0x8c>
lea    -0x2(%rbx),%eax
cmp    $0x3,%eax
jae    117d <scan_xml_handler+0x3d>
mov    0x2ee1(%rip),%eax
cmp    $0x2,%eax
je     11b0 <scan_xml_handler+0x70>
cmp    $0x1,%eax
je     11bc <scan_xml_handler+0x7c>
test   %eax,%eax
jne    11cc <scan_xml_handler+0x8c>
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <scan_xml_preamble_section@plt>
jmp    11c6 <scan_xml_handler+0x86>
test   %ebx,%ebx
jne    11cc <scan_xml_handler+0x8c>
movl   $0x0,0x2eb9(%rip)
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <scan_xml_preamble_section@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1060 <scan_xml_tracks_section@plt>
xor    %edi,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <scan_xml_playlists_section@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <scan_xml_playlists_section@plt>
jmp    11c6 <scan_xml_handler+0x86>
mov    %ebx,%edi
mov    %r14,%rsi
call   1060 <scan_xml_tracks_section@plt>
mov    %eax,0x2e78(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@scan_xml_handler.state = internal global i32 0
define void @scan_xml_handler(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = call i64 (...) @util_must_exit()
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %3
br label %39
10: ; preds = %3
%11 = load i32, i32* %4
switch i32 %11, label %38 [
i32 0, label %12
i32 2, label %22
i32 3, label %22
i32 4, label %22
]
12: ; preds = %10
store i32 0, i32* @scan_xml_handler.state
%13 = load i32, i32* %4
%14 = load i8*, i8** %6
%15 = call i32 @scan_xml_preamble_section(i32 %13, i8* %14)
%16 = load i32, i32* %4
%17 = load i8*, i8** %6
%18 = call i32 @scan_xml_tracks_section(i32 %16, i8* %17)
%19 = load i32, i32* %4
%20 = load i8*, i8** %6
%21 = call i32 @scan_xml_playlists_section(i32 %19, i8* %20)
br label %39
22: ; preds = %10, %10, %10
%23 = load i32, i32* @scan_xml_handler.state
switch i32 %23, label %36 [
i32 0, label %24
i32 1, label %28
i32 2, label %32
]
24: ; preds = %22
%25 = load i32, i32* %4
%26 = load i8*, i8** %6
%27 = call i32 @scan_xml_preamble_section(i32 %25, i8* %26)
store i32 %27, i32* @scan_xml_handler.state
br label %37
28: ; preds = %22
%29 = load i32, i32* %4
%30 = load i8*, i8** %6
%31 = call i32 @scan_xml_tracks_section(i32 %29, i8* %30)
store i32 %31, i32* @scan_xml_handler.state
br label %37
32: ; preds = %22
%33 = load i32, i32* %4
%34 = load i8*, i8** %6
%35 = call i32 @scan_xml_playlists_section(i32 %33, i8* %34)
store i32 %35, i32* @scan_xml_handler.state
br label %37
36: ; preds = %22
br label %37
37: ; preds = %36, %32, %28, %24
br label %38
38: ; preds = %10, %37
br label %39
39: ; preds = %9, %38, %12
ret void
}

LLVM IR (-O2):
@scan_xml_handler.state = internal unnamed_addr global i32 0
define void @scan_xml_handler(i32 %0, i8* nocapture readnone %1, i8* %2) {
%4 = tail call i64 (...) @util_must_exit()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %3
switch i32 %0, label %19 [
i32 0, label %7
i32 2, label %11
i32 3, label %11
i32 4, label %11
]
7: ; preds = %6
store i32 0, i32* @scan_xml_handler.state
%8 = tail call i32 @scan_xml_preamble_section(i32 0, i8* %2)
%9 = tail call i32 @scan_xml_tracks_section(i32 0, i8* %2)
%10 = tail call i32 @scan_xml_playlists_section(i32 0, i8* %2)
br label %19
11: ; preds = %6, %6, %6
%12 = load i32, i32* @scan_xml_handler.state
switch i32 %12, label %19 [
i32 0, label %13
i32 1, label %15
i32 2, label %17
]
13: ; preds = %11
%14 = tail call i32 @scan_xml_preamble_section(i32 %0, i8* %2)
store i32 %14, i32* @scan_xml_handler.state
br label %19
15: ; preds = %11
%16 = tail call i32 @scan_xml_tracks_section(i32 %0, i8* %2)
store i32 %16, i32* @scan_xml_handler.state
br label %19
17: ; preds = %11
%18 = tail call i32 @scan_xml_playlists_section(i32 %0, i8* %2)
store i32 %18, i32* @scan_xml_handler.state
br label %19
19: ; preds = %6, %11, %17, %15, %13, %3, %7
ret void
}