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

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int lb_add(struct lb *, int, int, char const *, int, char *, int, char *,
           void const *);
char *strdup(char const *);
int lb_discr(struct lb *p, int width_word, const char *word, int width_pre,
             const char *pre, int width_post, const char *post,
             const void *info) {
  char *p1, *p2;
  int rc;
  if (pre == NULL)
    p1 = NULL;
  else {
    p1 = strdup(pre);
    if (p1 == NULL)
      return 1;
  }
  if (post == NULL)
    p2 = NULL;
  else {
    p2 = strdup(post);
    if (p2 == NULL) {
      if (p1 != NULL)
        free(p1);
      return 1;
    }
  }
  rc = lb_add(p, 4, width_word, word, width_pre, p1, width_post, p2, info);
  if (rc != 0) {
    if (p1 != NULL)
      free(p1);
    if (p2 != NULL)
      free(p2);
  }
  return rc;
}


x86 assembly (clang, -O0):
<lb_discr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    116e <lb_discr+0x3e>
movq   $0x0,-0x40(%rbp)
jmp    1197 <lb_discr+0x67>
mov    -0x30(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1192 <lb_discr+0x62>
movl   $0x1,-0x4(%rbp)
jmp    1263 <lb_discr+0x133>
jmp    1197 <lb_discr+0x67>
cmpq   $0x0,0x10(%rbp)
jne    11af <lb_discr+0x7f>
movq   $0x0,-0x48(%rbp)
jmp    11ec <lb_discr+0xbc>
mov    0x10(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11e7 <lb_discr+0xb7>
cmpq   $0x0,-0x40(%rbp)
je     11db <lb_discr+0xab>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1263 <lb_discr+0x133>
jmp    11ec <lb_discr+0xbc>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x40(%rbp),%r9
mov    -0x34(%rbp),%r11d
mov    -0x48(%rbp),%r10
mov    0x18(%rbp),%rax
mov    $0x4,%esi
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <lb_add@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     125d <lb_discr+0x12d>
cmpq   $0x0,-0x40(%rbp)
je     1244 <lb_discr+0x114>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x48(%rbp)
je     1258 <lb_discr+0x128>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
jmp    125d <lb_discr+0x12d>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lb_discr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r15d
mov    %ecx,%r14d
mov    %rdx,%r13
mov    %esi,%ebp
mov    %rdi,%rbx
test   %r8,%r8
je     116b <lb_discr+0x3b>
mov    %r8,%rdi
call   1050 <strdup@plt>
mov    %rax,%r12
test   %rax,%rax
jne    116e <lb_discr+0x3e>
mov    $0x1,%ebx
jmp    11f8 <lb_discr+0xc8>
xor    %r12d,%r12d
mov    %rbx,0x8(%rsp)
mov    0x50(%rsp),%rdi
xor    %ebx,%ebx
test   %rdi,%rdi
mov    %r15,0x10(%rsp)
je     11a5 <lb_discr+0x75>
call   1050 <strdup@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11a8 <lb_discr+0x78>
mov    $0x1,%ebp
mov    %r12,%r15
mov    $0x1,%ebx
test   %r12,%r12
jne    11ee <lb_discr+0xbe>
jmp    11f8 <lb_discr+0xc8>
xor    %r15d,%r15d
sub    $0x8,%rsp
mov    0x10(%rsp),%rdi
mov    $0x4,%esi
mov    %ebp,%edx
mov    %r13,%rcx
mov    %r14d,%r8d
mov    %r12,%r9
push   0x60(%rsp)
push   %r15
push   0x28(%rsp)
call   1040 <lb_add@plt>
add    $0x20,%rsp
test   %eax,%eax
je     11f8 <lb_discr+0xc8>
mov    %eax,%ebp
test   %r12,%r12
je     11e7 <lb_discr+0xb7>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %ebp,%ebx
test   %r15,%r15
je     11f8 <lb_discr+0xc8>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.lb = type { i32 }
define i32 @lb_discr(%struct.lb* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5, i8* %6, i8* %7) {
%9 = alloca i32
%10 = alloca %struct.lb*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i32
store %struct.lb* %0, %struct.lb** %10
store i32 %1, i32* %11
store i8* %2, i8** %12
store i32 %3, i32* %13
store i8* %4, i8** %14
store i32 %5, i32* %15
store i8* %6, i8** %16
store i8* %7, i8** %17
%21 = load i8*, i8** %14
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %24
23: ; preds = %8
store i8* null, i8** %18
br label %31
24: ; preds = %8
%25 = load i8*, i8** %14
%26 = call i8* @strdup(i8* %25)
store i8* %26, i8** %18
%27 = load i8*, i8** %18
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 1, i32* %9
br label %75
30: ; preds = %24
br label %31
31: ; preds = %30, %23
%32 = load i8*, i8** %16
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %35
34: ; preds = %31
store i8* null, i8** %19
br label %48
35: ; preds = %31
%36 = load i8*, i8** %16
%37 = call i8* @strdup(i8* %36)
store i8* %37, i8** %19
%38 = load i8*, i8** %19
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %47
40: ; preds = %35
%41 = load i8*, i8** %18
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i8*, i8** %18
%45 = call i32 @free(i8* %44)
br label %46
46: ; preds = %43, %40
store i32 1, i32* %9
br label %75
47: ; preds = %35
br label %48
48: ; preds = %47, %34
%49 = load %struct.lb*, %struct.lb** %10
%50 = load i32, i32* %11
%51 = load i8*, i8** %12
%52 = load i32, i32* %13
%53 = load i8*, i8** %18
%54 = load i32, i32* %15
%55 = load i8*, i8** %19
%56 = load i8*, i8** %17
%57 = call i32 @lb_add(%struct.lb* %49, i32 4, i32 %50, i8* %51, i32 %52, i8* %53, i32 %54, i8* %55, i8* %56)
store i32 %57, i32* %20
%58 = load i32, i32* %20
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %73
60: ; preds = %48
%61 = load i8*, i8** %18
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = load i8*, i8** %18
%65 = call i32 @free(i8* %64)
br label %66
66: ; preds = %63, %60
%67 = load i8*, i8** %19
%68 = icmp ne i8* %67, null
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = load i8*, i8** %19
%71 = call i32 @free(i8* %70)
br label %72
72: ; preds = %69, %66
br label %73
73: ; preds = %72, %48
%74 = load i32, i32* %20
store i32 %74, i32* %9
br label %75
75: ; preds = %73, %46, %29
%76 = load i32, i32* %9
ret i32 %76
}

LLVM IR (-O2):
%struct.lb = type { i32 }
define i32 @lb_discr(%struct.lb* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5, i8* %6, i8* %7) {
%9 = icmp eq i8* %4, null
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = tail call i8* @strdup(i8* %4)
%12 = icmp eq i8* %11, null
br i1 %12, label %35, label %13
13: ; preds = %8, %10
%14 = phi i8* [ %11, %10 ], [ null, %8 ]
%15 = icmp eq i8* %6, null
br i1 %15, label %21, label %16
16: ; preds = %13
%17 = tail call i8* @strdup(i8* %6)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = icmp eq i8* %14, null
br i1 %20, label %35, label %31
21: ; preds = %13, %16
%22 = phi i8* [ %17, %16 ], [ null, %13 ]
%23 = tail call i32 @lb_add(%struct.lb* %0, i32 4, i32 %1, i8* %2, i32 %3, i8* %14, i32 %5, i8* %22, i8* %7)
%24 = icmp eq i32 %23, 0
br i1 %24, label %35, label %25
25: ; preds = %21
%26 = icmp eq i8* %14, null
br i1 %26, label %29, label %27
27: ; preds = %25
%28 = tail call i32 @free(i8* %14)
br label %29
29: ; preds = %27, %25
%30 = icmp eq i8* %22, null
br i1 %30, label %35, label %31
31: ; preds = %29, %19
%32 = phi i8* [ %14, %19 ], [ %22, %29 ]
%33 = phi i32 [ 1, %19 ], [ %23, %29 ]
%34 = tail call i32 @free(i8* %32)
br label %35
35: ; preds = %31, %21, %29, %19, %10
%36 = phi i32 [ 1, %10 ], [ 1, %19 ], [ %23, %29 ], [ 0, %21 ], [ %33, %31 ]
ret i32 %36
}