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

/* Variables and functions */
int /*<<< orphan*/ addCategory(char *, struct Categories **);
int /*<<< orphan*/ addProduct(struct Categories **, int, char *, double, char *,
                              int, char **);
int /*<<< orphan*/ buyProduct(int, struct Categories **);
int /*<<< orphan*/ printStore(struct Categories *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ removeCategory(char *, struct Categories **);
int /*<<< orphan*/ search(char *, double, struct Categories *);
void test4() {
  struct Categories *head = NULL;
  char *names[] = {"Electronics", "Books", "Computers", "Grocery"};
  addProduct(&head, 1, "Canon SD1300 IS", 229.00, "Amazon", 1, names);
  addCategory("Electronics", &head);
  addCategory("Books", &head);
  addCategory("Computers", &head);
  addProduct(&head, 2, "Programming in C", 60.00, "ABC-Bookstore", 1,
             names + 1);
  addProduct(&head, 3, "IPOD Shuffle", 49.00, "Apple", 1, names);
  addProduct(&head, 4, "Amazon Kindle", 139.00, "Amazon", 2, names);
  addProduct(&head, 5, "Apples", 3.49, "Walmart", 1, names + 3);
  printStore(head);
  printf("\nSearch before buying product 1\n");
  search("Electronics", 300.00, head);
  buyProduct(1, &head);
  printf("\nSearch after buying product 1\n");
  search("Electronics", 300.00, head);
  buyProduct(1, &head);
  removeCategory("Electronics", &head);
  buyProduct(1, &head);
  printStore(head);
}


x86 assembly (clang, -O0):
<test4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x8(%rbp)
mov    0x2c79(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c76(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c73(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c70(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x30(%rbp),%r9
lea    -0x8(%rbp),%rdi
mov    $0x1,%r8d
lea    0xe93(%rip),%rdx
movsd  0xe5f(%rip),%xmm0
lea    0xe94(%rip),%rcx
mov    %r8d,%esi
call   1050 <addProduct@plt>
lea    0xe51(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <addCategory@plt>
lea    0xe4d(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <addCategory@plt>
lea    0xe43(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1080 <addCategory@plt>
lea    -0x30(%rbp),%r9
add    $0x8,%r9
lea    -0x8(%rbp),%rdi
mov    $0x2,%esi
lea    0xe4b(%rip),%rdx
movsd  0xdf8(%rip),%xmm0
lea    0xe4d(%rip),%rcx
mov    $0x1,%r8d
call   1050 <addProduct@plt>
lea    -0x30(%rbp),%r9
lea    -0x8(%rbp),%rdi
mov    $0x3,%esi
lea    0xe3c(%rip),%rdx
movsd  0xdc2(%rip),%xmm0
lea    0xe3a(%rip),%rcx
mov    $0x1,%r8d
call   1050 <addProduct@plt>
lea    -0x30(%rbp),%r9
lea    -0x8(%rbp),%rdi
mov    $0x4,%esi
lea    0xe21(%rip),%rdx
movsd  0xd8c(%rip),%xmm0
lea    0xdd9(%rip),%rcx
mov    $0x2,%r8d
call   1050 <addProduct@plt>
lea    -0x30(%rbp),%r9
add    $0x18,%r9
lea    -0x8(%rbp),%rdi
mov    $0x5,%esi
lea    0xdfd(%rip),%rdx
movsd  0xd52(%rip),%xmm0
lea    0xdf5(%rip),%rcx
mov    $0x1,%r8d
call   1050 <addProduct@plt>
mov    -0x8(%rbp),%rdi
call   1070 <printStore@plt>
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xd48(%rip),%rdi
movsd  0xd10(%rip),%xmm0
call   1060 <search@plt>
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
call   1030 <buyProduct@plt>
lea    0xdd1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xd16(%rip),%rdi
movsd  0xcde(%rip),%xmm0
call   1060 <search@plt>
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
call   1030 <buyProduct@plt>
lea    0xcf4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1090 <removeCategory@plt>
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
call   1030 <buyProduct@plt>
mov    -0x8(%rbp),%rdi
call   1070 <printStore@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test4>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
movq   $0x0,0x8(%rsp)
movaps 0x2c85(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2c69(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xeb1(%rip),%rdx
lea    0xeba(%rip),%r15
lea    0x8(%rsp),%rbx
movsd  0xe49(%rip),%xmm0
lea    0x10(%rsp),%r12
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r15,%rcx
mov    $0x1,%r8d
mov    %r12,%r9
call   1050 <addProduct@plt>
lea    0xe54(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <addCategory@plt>
lea    0xe4e(%rip),%rdi
mov    %rbx,%rsi
call   1080 <addCategory@plt>
lea    0xe45(%rip),%rdi
mov    %rbx,%rsi
call   1080 <addCategory@plt>
lea    0x18(%rsp),%r9
lea    0xe5a(%rip),%rdx
lea    0xe64(%rip),%rcx
movsd  0xde8(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%r8d
call   1050 <addProduct@plt>
lea    0xe50(%rip),%rdx
lea    0xe56(%rip),%rcx
movsd  0xdc7(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x1,%r8d
mov    %r12,%r9
call   1050 <addProduct@plt>
lea    0xe37(%rip),%rdx
movsd  0xdaa(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r15,%rcx
mov    $0x2,%r8d
mov    %r12,%r9
call   1050 <addProduct@plt>
lea    0x28(%rsp),%r9
lea    0xe18(%rip),%rdx
lea    0xe18(%rip),%rcx
movsd  0xd7e(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x1,%r8d
call   1050 <addProduct@plt>
mov    0x8(%rsp),%rdi
call   1070 <printStore@plt>
lea    0xdf4(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rsi
movsd  0xd50(%rip),%xmm0
mov    %r14,%rdi
call   1060 <search@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1040 <buyProduct@plt>
lea    0xde6(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
movsd  0xd1f(%rip),%xmm0
call   1060 <search@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1040 <buyProduct@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <removeCategory@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1040 <buyProduct@plt>
mov    0x8(%rsp),%rdi
call   1070 <printStore@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.Categories = type { i32 }
@.str = [12 x i8] c"Electronics\00"
@.str.1 = [6 x i8] c"Books\00"
@.str.2 = [10 x i8] c"Computers\00"
@.str.3 = [8 x i8] c"Grocery\00"
@__const.test4.names = [4 x i8*] [i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [16 x i8] c"Canon SD1300 IS\00"
@.str.5 = [7 x i8] c"Amazon\00"
@.str.6 = [17 x i8] c"Programming in C\00"
@.str.7 = [14 x i8] c"ABC-Bookstore\00"
@.str.8 = [13 x i8] c"IPOD Shuffle\00"
@.str.9 = [6 x i8] c"Apple\00"
@.str.10 = [14 x i8] c"Amazon Kindle\00"
@.str.11 = [7 x i8] c"Apples\00"
@.str.12 = [8 x i8] c"Walmart\00"
@.str.13 = [33 x i8] c"\0ASearch before buying product 1\0A\00"
@.str.14 = [32 x i8] c"\0ASearch after buying product 1\0A\00"
define void @test4() {
%1 = alloca %struct.Categories*
%2 = alloca [4 x i8*]
store %struct.Categories* null, %struct.Categories** %1
%3 = bitcast [4 x i8*]* %2 to i8*
%4 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%5 = call i32 @addProduct(%struct.Categories** %1, i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double 2.290000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 1, i8** %4)
%6 = call i32 @addCategory(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.Categories** %1)
%7 = call i32 @addCategory(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %struct.Categories** %1)
%8 = call i32 @addCategory(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.Categories** %1)
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = call i32 @addProduct(%struct.Categories** %1, i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), double 6.000000e+01, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 1, i8** %10)
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%13 = call i32 @addProduct(%struct.Categories** %1, i32 3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), double 4.900000e+01, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 1, i8** %12)
%14 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%15 = call i32 @addProduct(%struct.Categories** %1, i32 4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), double 1.390000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 2, i8** %14)
%16 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%17 = getelementptr inbounds i8*, i8** %16, i64 3
%18 = call i32 @addProduct(%struct.Categories** %1, i32 5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), double 3.490000e+00, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 1, i8** %17)
%19 = load %struct.Categories*, %struct.Categories** %1
%20 = call i32 @printStore(%struct.Categories* %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0))
%22 = load %struct.Categories*, %struct.Categories** %1
%23 = call i32 @search(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double 3.000000e+02, %struct.Categories* %22)
%24 = call i32 @buyProduct(i32 1, %struct.Categories** %1)
%25 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0))
%26 = load %struct.Categories*, %struct.Categories** %1
%27 = call i32 @search(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double 3.000000e+02, %struct.Categories* %26)
%28 = call i32 @buyProduct(i32 1, %struct.Categories** %1)
%29 = call i32 @removeCategory(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.Categories** %1)
%30 = call i32 @buyProduct(i32 1, %struct.Categories** %1)
%31 = load %struct.Categories*, %struct.Categories** %1
%32 = call i32 @printStore(%struct.Categories* %31)
ret void
}

LLVM IR (-O2):
%struct.Categories = type { i32 }
@.str = [12 x i8] c"Electronics\00"
@.str.1 = [6 x i8] c"Books\00"
@.str.2 = [10 x i8] c"Computers\00"
@.str.3 = [8 x i8] c"Grocery\00"
@__const.test4.names = [4 x i8*] [i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [16 x i8] c"Canon SD1300 IS\00"
@.str.5 = [7 x i8] c"Amazon\00"
@.str.6 = [17 x i8] c"Programming in C\00"
@.str.7 = [14 x i8] c"ABC-Bookstore\00"
@.str.8 = [13 x i8] c"IPOD Shuffle\00"
@.str.9 = [6 x i8] c"Apple\00"
@.str.10 = [14 x i8] c"Amazon Kindle\00"
@.str.11 = [7 x i8] c"Apples\00"
@.str.12 = [8 x i8] c"Walmart\00"
@str = [32 x i8] c"\0ASearch before buying product 1\00"
@str.15 = [31 x i8] c"\0ASearch after buying product 1\00"
define void @test4() {
%1 = alloca %struct.Categories*
%2 = alloca [4 x i8*]
%3 = bitcast %struct.Categories** %1 to i8*
store %struct.Categories* null, %struct.Categories** %1
%4 = bitcast [4 x i8*]* %2 to i8*
%5 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%6 = call i32 @addProduct(%struct.Categories** %1, i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double 2.290000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 1, i8** %5)
%7 = call i32 @addCategory(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.Categories** %1)
%8 = call i32 @addCategory(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %struct.Categories** %1)
%9 = call i32 @addCategory(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.Categories** %1)
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
%11 = call i32 @addProduct(%struct.Categories** %1, i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), double 6.000000e+01, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 1, i8** %10)
%12 = call i32 @addProduct(%struct.Categories** %1, i32 3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), double 4.900000e+01, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 1, i8** %5)
%13 = call i32 @addProduct(%struct.Categories** %1, i32 4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), double 1.390000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 2, i8** %5)
%14 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
%15 = call i32 @addProduct(%struct.Categories** %1, i32 5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), double 3.490000e+00, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i32 1, i8** %14)
%16 = load %struct.Categories*, %struct.Categories** %1
%17 = call i32 @printStore(%struct.Categories* %16)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%19 = load %struct.Categories*, %struct.Categories** %1
%20 = call i32 @search(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double 3.000000e+02, %struct.Categories* %19)
%21 = call i32 @buyProduct(i32 1, %struct.Categories** %1)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.15, i64 0, i64 0))
%23 = load %struct.Categories*, %struct.Categories** %1
%24 = call i32 @search(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double 3.000000e+02, %struct.Categories* %23)
%25 = call i32 @buyProduct(i32 1, %struct.Categories** %1)
%26 = call i32 @removeCategory(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.Categories** %1)
%27 = call i32 @buyProduct(i32 1, %struct.Categories** %1)
%28 = load %struct.Categories*, %struct.Categories** %1
%29 = call i32 @printStore(%struct.Categories* %28)
ret void
}