#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 db_warehouse_create_product(char *);
int db_warehouse_exists_product(char *);
int db_warehouse_set_internal_data(char *, void *, int);
int sequential_create_product(char *product_name) {
  int ret;
  int size;
  void *st_int;
  ret = db_warehouse_exists_product(product_name);
  if (ret == 0) {
    ret = db_warehouse_create_product(product_name);
    if (ret == 0) {
      size = 0;
      st_int = NULL;
      ret = db_warehouse_set_internal_data(product_name, st_int, size);
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<sequential_create_product>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <db_warehouse_exists_product@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    118f <sequential_create_product+0x5f>
mov    -0x8(%rbp),%rdi
call   1040 <db_warehouse_create_product@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    118a <sequential_create_product+0x5a>
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1030 <db_warehouse_set_internal_data@plt>
mov    %eax,-0xc(%rbp)
jmp    118f <sequential_create_product+0x5f>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sequential_create_product>:
push   %rbx
mov    %rdi,%rbx
call   1050 <db_warehouse_exists_product@plt>
test   %eax,%eax
jne    1149 <sequential_create_product+0x19>
mov    %rbx,%rdi
call   1040 <db_warehouse_create_product@plt>
test   %eax,%eax
je     114b <sequential_create_product+0x1b>
pop    %rbx
ret
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
pop    %rbx
jmp    1030 <db_warehouse_set_internal_data@plt>

LLVM IR (-O0):
define i32 @sequential_create_product(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @db_warehouse_exists_product(i8* %6)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i32 @db_warehouse_create_product(i8* %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %10
store i32 0, i32* %4
store i8* null, i8** %5
%16 = load i8*, i8** %2
%17 = load i8*, i8** %5
%18 = load i32, i32* %4
%19 = call i32 @db_warehouse_set_internal_data(i8* %16, i8* %17, i32 %18)
store i32 %19, i32* %3
br label %20
20: ; preds = %15, %10
br label %21
21: ; preds = %20, %1
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
define i32 @sequential_create_product(i8* %0) {
%2 = tail call i32 @db_warehouse_exists_product(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = tail call i32 @db_warehouse_create_product(i8* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @db_warehouse_set_internal_data(i8* %0, i8* null, i32 0)
br label %9
9: ; preds = %4, %7, %1
%10 = phi i32 [ %8, %7 ], [ %5, %4 ], [ %2, %1 ]
ret i32 %10
}