#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sequential_create_product(char *);
int /*<<< orphan*/ sequential_decrement_stock(char *, int, int *);
int /*<<< orphan*/ sequential_delete_product(char *);
int /*<<< orphan*/ sequential_get_stock(char *, int *);
int /*<<< orphan*/ sequential_increment_stock(char *, int, int *);
void example(void) {
  int stock = 100, updated_stock = 0;
  char *product_name = "product1";
  printf("Executing sequential example \n");
  printf("Creating product %s. \n", product_name);
  sequential_create_product(product_name);
  printf("Created product %s. \n", product_name);
  printf("Incrementing stock in %d units in product %s. \n", stock,
         product_name);
  sequential_increment_stock(product_name, stock, &updated_stock);
  printf("Stock incremented in product %s, new stock: %d units. \n",
         product_name, updated_stock);
  printf("Decrementing stock in %d units in product %s. \n", stock,
         product_name);
  sequential_decrement_stock(product_name, stock, &updated_stock);
  printf("Decremented stock in product %s, new stock: %d units. \n",
         product_name, updated_stock);
  printf("Obteining stock from product %s. \n", product_name);
  sequential_get_stock(product_name, &stock);
  printf("Stock obtained. The product %s has an stock of %d units. \n",
         product_name, stock);
  printf("Deleting product %s. \n", product_name);
  sequential_delete_product(product_name);
  printf("Deleted %s deleted. \n", product_name);
}


x86 assembly (clang, -O0):
<example>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x64,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe83(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <sequential_create_product@plt>
mov    -0x10(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
lea    -0x8(%rbp),%rdx
call   1040 <sequential_increment_stock@plt>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
lea    -0x8(%rbp),%rdx
call   1070 <sequential_decrement_stock@plt>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x4(%rbp),%rsi
call   1080 <sequential_get_stock@plt>
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%edx
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xf14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <sequential_delete_product@plt>
mov    -0x10(%rbp),%rsi
lea    0xf10(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<example>:
push   %r14
push   %rbx
push   %rax
movl   $0x64,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0x1007(%rip),%rdi
call   1040 <puts@plt>
lea    0xe73(%rip),%rdi
lea    0xe63(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <sequential_create_product@plt>
lea    0xe6a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe6f(%rip),%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%r14
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1050 <sequential_increment_stock@plt>
mov    (%rsp),%edx
lea    0xe73(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe9a(%rip),%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1080 <sequential_decrement_stock@plt>
mov    (%rsp),%edx
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xec8(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1090 <sequential_get_stock@plt>
mov    0x4(%rsp),%edx
lea    0xec9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xef3(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1070 <sequential_delete_product@plt>
lea    0xef1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"product1\00"
@.str.1 = [31 x i8] c"Executing sequential example \0A\00"
@.str.2 = [23 x i8] c"Creating product %s. \0A\00"
@.str.3 = [22 x i8] c"Created product %s. \0A\00"
@.str.4 = [48 x i8] c"Incrementing stock in %d units in product %s. \0A\00"
@.str.5 = [56 x i8] c"Stock incremented in product %s, new stock: %d units. \0A\00"
@.str.6 = [48 x i8] c"Decrementing stock in %d units in product %s. \0A\00"
@.str.7 = [56 x i8] c"Decremented stock in product %s, new stock: %d units. \0A\00"
@.str.8 = [35 x i8] c"Obteining stock from product %s. \0A\00"
@.str.9 = [59 x i8] c"Stock obtained. The product %s has an stock of %d units. \0A\00"
@.str.10 = [23 x i8] c"Deleting product %s. \0A\00"
@.str.11 = [22 x i8] c"Deleted %s deleted. \0A\00"
define void @example() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
store i32 100, i32* %1
store i32 0, i32* %2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%5 = load i8*, i8** %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %3
%8 = call i32 @sequential_create_product(i8* %7)
%9 = load i8*, i8** %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = load i32, i32* %1
%12 = load i8*, i8** %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i32 %11, i8* %12)
%14 = load i8*, i8** %3
%15 = load i32, i32* %1
%16 = call i32 @sequential_increment_stock(i8* %14, i32 %15, i32* %2)
%17 = load i8*, i8** %3
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i8* %17, i32 %18)
%20 = load i32, i32* %1
%21 = load i8*, i8** %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i32 %20, i8* %21)
%23 = load i8*, i8** %3
%24 = load i32, i32* %1
%25 = call i32 @sequential_decrement_stock(i8* %23, i32 %24, i32* %2)
%26 = load i8*, i8** %3
%27 = load i32, i32* %2
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0), i8* %26, i32 %27)
%29 = load i8*, i8** %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i8* %29)
%31 = load i8*, i8** %3
%32 = call i32 @sequential_get_stock(i8* %31, i32* %1)
%33 = load i8*, i8** %3
%34 = load i32, i32* %1
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.9, i64 0, i64 0), i8* %33, i32 %34)
%36 = load i8*, i8** %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* %36)
%38 = load i8*, i8** %3
%39 = call i32 @sequential_delete_product(i8* %38)
%40 = load i8*, i8** %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* %40)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"product1\00"
@.str.2 = [23 x i8] c"Creating product %s. \0A\00"
@.str.3 = [22 x i8] c"Created product %s. \0A\00"
@.str.4 = [48 x i8] c"Incrementing stock in %d units in product %s. \0A\00"
@.str.5 = [56 x i8] c"Stock incremented in product %s, new stock: %d units. \0A\00"
@.str.6 = [48 x i8] c"Decrementing stock in %d units in product %s. \0A\00"
@.str.7 = [56 x i8] c"Decremented stock in product %s, new stock: %d units. \0A\00"
@.str.8 = [35 x i8] c"Obteining stock from product %s. \0A\00"
@.str.9 = [59 x i8] c"Stock obtained. The product %s has an stock of %d units. \0A\00"
@.str.10 = [23 x i8] c"Deleting product %s. \0A\00"
@.str.11 = [22 x i8] c"Deleted %s deleted. \0A\00"
@str = [30 x i8] c"Executing sequential example \00"
define void @example() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 100, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @sequential_create_product(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i32 100, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @sequential_increment_stock(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 100, i32* %2)
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i32 100, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @sequential_decrement_stock(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 100, i32* %2)
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @sequential_get_stock(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1)
%19 = load i32, i32* %1
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @sequential_delete_product(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
ret void
}