#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*/ printStore(struct Categories *);
void test1() {
  struct Categories *head = NULL;
  char *names[] = {"Electronics", "Books", "Computers", "Grocery"};
  addCategory("Computers", &head);
  addProduct(&head, 1, "DELL Laptop", 799.00, "Dell", 1, names + 2);
  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, "Canon SD1300 IS", 229.00, "Amazon", 1, names);
  addProduct(&head, 5, "Amazon Kindle", 139.00, "Amazon", 2, names);
  printStore(head);
}


x86 assembly (clang, -O0):
<test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x8(%rbp)
mov    0x2cb9(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cb6(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cb3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cb0(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <addCategory@plt>
lea    -0x30(%rbp),%r9
add    $0x10,%r9
lea    -0x8(%rbp),%rdi
mov    $0x1,%r8d
lea    0xeb7(%rip),%rdx
movsd  0xe83(%rip),%xmm0
lea    0xeb4(%rip),%rcx
mov    %r8d,%esi
call   1030 <addProduct@plt>
lea    -0x30(%rbp),%r9
add    $0x8,%r9
lea    -0x8(%rbp),%rdi
mov    $0x2,%esi
lea    0xe99(%rip),%rdx
movsd  0xe4c(%rip),%xmm0
lea    0xe9b(%rip),%rcx
mov    $0x1,%r8d
call   1030 <addProduct@plt>
lea    -0x30(%rbp),%r9
lea    -0x8(%rbp),%rdi
mov    $0x3,%esi
lea    0xe8a(%rip),%rdx
movsd  0xe16(%rip),%xmm0
lea    0xe88(%rip),%rcx
mov    $0x1,%r8d
call   1030 <addProduct@plt>
lea    -0x30(%rbp),%r9
lea    -0x8(%rbp),%rdi
mov    $0x4,%esi
lea    0xe6f(%rip),%rdx
movsd  0xde0(%rip),%xmm0
lea    0xe70(%rip),%rcx
mov    $0x1,%r8d
call   1030 <addProduct@plt>
lea    -0x30(%rbp),%r9
lea    -0x8(%rbp),%rdi
mov    $0x5,%esi
lea    0xe58(%rip),%rdx
movsd  0xdaa(%rip),%xmm0
lea    0xe42(%rip),%rcx
mov    $0x2,%r8d
call   1030 <addProduct@plt>
mov    -0x8(%rbp),%rdi
call   1040 <printStore@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movq   $0x0,0x8(%rsp)
movaps 0x2cc7(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2cab(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x20(%rsp),%r14
lea    0xed4(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <addCategory@plt>
lea    0xed2(%rip),%rdx
lea    0xed7(%rip),%rcx
movsd  0xe77(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%r8d
mov    %r14,%r9
call   1030 <addProduct@plt>
lea    0x18(%rsp),%r9
lea    0xeb2(%rip),%rdx
lea    0xebc(%rip),%rcx
movsd  0xe4e(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%r8d
call   1030 <addProduct@plt>
lea    0xea8(%rip),%rdx
lea    0xeae(%rip),%rcx
movsd  0xe2d(%rip),%xmm0
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x1,%r8d
mov    %r14,%r9
call   1030 <addProduct@plt>
lea    0xe8a(%rip),%rdx
lea    0xe93(%rip),%r15
movsd  0xe04(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r15,%rcx
mov    $0x1,%r8d
mov    %r14,%r9
call   1030 <addProduct@plt>
lea    0xe72(%rip),%rdx
movsd  0xde4(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %r15,%rcx
mov    $0x2,%r8d
mov    %r14,%r9
call   1030 <addProduct@plt>
mov    0x8(%rsp),%rdi
call   1040 <printStore@plt>
add    $0x30,%rsp
pop    %rbx
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.test1.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 = [12 x i8] c"DELL Laptop\00"
@.str.5 = [5 x i8] c"Dell\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 = [16 x i8] c"Canon SD1300 IS\00"
@.str.11 = [7 x i8] c"Amazon\00"
@.str.12 = [14 x i8] c"Amazon Kindle\00"
define void @test1() {
%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 = call i32 @addCategory(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.Categories** %1)
%5 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%6 = getelementptr inbounds i8*, i8** %5, i64 2
%7 = call i32 @addProduct(%struct.Categories** %1, i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double 7.990000e+02, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 1, i8** %6)
%8 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = 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** %9)
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%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** %11)
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%14 = call i32 @addProduct(%struct.Categories** %1, i32 4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), double 2.290000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 1, i8** %13)
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%16 = call i32 @addProduct(%struct.Categories** %1, i32 5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), double 1.390000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 2, i8** %15)
%17 = load %struct.Categories*, %struct.Categories** %1
%18 = call i32 @printStore(%struct.Categories* %17)
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.test1.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 = [12 x i8] c"DELL Laptop\00"
@.str.5 = [5 x i8] c"Dell\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 = [16 x i8] c"Canon SD1300 IS\00"
@.str.11 = [7 x i8] c"Amazon\00"
@.str.12 = [14 x i8] c"Amazon Kindle\00"
define void @test1() {
%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 = call i32 @addCategory(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.Categories** %1)
%6 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%7 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
%8 = call i32 @addProduct(%struct.Categories** %1, i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double 7.990000e+02, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 1, i8** %7)
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
%10 = 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** %9)
%11 = 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** %6)
%12 = call i32 @addProduct(%struct.Categories** %1, i32 4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), double 2.290000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 1, i8** %6)
%13 = call i32 @addProduct(%struct.Categories** %1, i32 5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), double 1.390000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 2, i8** %6)
%14 = load %struct.Categories*, %struct.Categories** %1
%15 = call i32 @printStore(%struct.Categories* %14)
ret void
}