#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*/ addProduct(struct Categories **, int, char *, double, char *,
                              int, char **);
int /*<<< orphan*/ buyProduct(int, struct Categories **);
int /*<<< orphan*/ printStore(struct Categories *);
void test3() {
  struct Categories *head = NULL;
  char *names[] = {"Electronics", "Books", "Computers"};
  buyProduct(3, &head);
  addProduct(&head, 1, "Canon SD1300 IS", 229.00, "Amazon", 1, names);
  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);
  buyProduct(8, &head);
  buyProduct(3, &head);
  printStore(head);
  buyProduct(4, &head);
  printStore(head);
}


x86 assembly (clang, -O0):
<test3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
mov    0x2cb9(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cb6(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2cb3(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x3,%edi
lea    -0x8(%rbp),%rsi
call   1030 <buyProduct@plt>
lea    -0x20(%rbp),%r9
lea    -0x8(%rbp),%rdi
mov    $0x1,%r8d
lea    0xeb8(%rip),%rdx
movsd  0xe8c(%rip),%xmm0
lea    0xeb9(%rip),%rcx
mov    %r8d,%esi
call   1040 <addProduct@plt>
lea    -0x20(%rbp),%r9
add    $0x8,%r9
lea    -0x8(%rbp),%rdi
mov    $0x2,%esi
lea    0xea0(%rip),%rdx
movsd  0xe55(%rip),%xmm0
lea    0xea2(%rip),%rcx
mov    $0x1,%r8d
call   1040 <addProduct@plt>
lea    -0x20(%rbp),%r9
lea    -0x8(%rbp),%rdi
mov    $0x3,%esi
lea    0xe91(%rip),%rdx
movsd  0xe1f(%rip),%xmm0
lea    0xe8f(%rip),%rcx
mov    $0x1,%r8d
call   1040 <addProduct@plt>
lea    -0x20(%rbp),%r9
lea    -0x8(%rbp),%rdi
mov    $0x4,%esi
lea    0xe76(%rip),%rdx
movsd  0xde9(%rip),%xmm0
lea    0xe2e(%rip),%rcx
mov    $0x2,%r8d
call   1040 <addProduct@plt>
mov    $0x8,%edi
lea    -0x8(%rbp),%rsi
call   1030 <buyProduct@plt>
mov    $0x3,%edi
lea    -0x8(%rbp),%rsi
call   1030 <buyProduct@plt>
mov    -0x8(%rbp),%rdi
call   1050 <printStore@plt>
mov    $0x4,%edi
lea    -0x8(%rbp),%rsi
call   1030 <buyProduct@plt>
mov    -0x8(%rbp),%rdi
call   1050 <printStore@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test3>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movq   $0x0,0x8(%rsp)
mov    0x2cc7(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0x2cab(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x8(%rsp),%rbx
mov    $0x3,%edi
mov    %rbx,%rsi
call   1030 <buyProduct@plt>
lea    0xec9(%rip),%rdx
lea    0xed2(%rip),%r14
movsd  0xe7e(%rip),%xmm0
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14,%rcx
mov    $0x1,%r8d
mov    %r15,%r9
call   1040 <addProduct@plt>
lea    0x18(%rsp),%r9
lea    0xea7(%rip),%rdx
lea    0xeb1(%rip),%rcx
movsd  0xe4d(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%r8d
call   1040 <addProduct@plt>
lea    0xe9d(%rip),%rdx
lea    0xea3(%rip),%rcx
movsd  0xe2c(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x1,%r8d
mov    %r15,%r9
call   1040 <addProduct@plt>
lea    0xe84(%rip),%rdx
movsd  0xe0f(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r14,%rcx
mov    $0x2,%r8d
mov    %r15,%r9
call   1040 <addProduct@plt>
mov    $0x8,%edi
mov    %rbx,%rsi
call   1030 <buyProduct@plt>
mov    $0x3,%edi
mov    %rbx,%rsi
call   1030 <buyProduct@plt>
mov    0x8(%rsp),%rdi
call   1050 <printStore@plt>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1030 <buyProduct@plt>
mov    0x8(%rsp),%rdi
call   1050 <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"
@__const.test3.names = [3 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)]
@.str.3 = [16 x i8] c"Canon SD1300 IS\00"
@.str.4 = [7 x i8] c"Amazon\00"
@.str.5 = [17 x i8] c"Programming in C\00"
@.str.6 = [14 x i8] c"ABC-Bookstore\00"
@.str.7 = [13 x i8] c"IPOD Shuffle\00"
@.str.8 = [6 x i8] c"Apple\00"
@.str.9 = [14 x i8] c"Amazon Kindle\00"
define void @test3() {
%1 = alloca %struct.Categories*
%2 = alloca [3 x i8*]
store %struct.Categories* null, %struct.Categories** %1
%3 = bitcast [3 x i8*]* %2 to i8*
%4 = call i32 @buyProduct(i32 3, %struct.Categories** %1)
%5 = getelementptr inbounds [3 x i8*], [3 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.3, i64 0, i64 0), double 2.290000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 1, i8** %5)
%7 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 0
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = call i32 @addProduct(%struct.Categories** %1, i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double 6.000000e+01, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 1, i8** %8)
%10 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 0
%11 = call i32 @addProduct(%struct.Categories** %1, i32 3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), double 4.900000e+01, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 1, i8** %10)
%12 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 0
%13 = call i32 @addProduct(%struct.Categories** %1, i32 4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), double 1.390000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 2, i8** %12)
%14 = call i32 @buyProduct(i32 8, %struct.Categories** %1)
%15 = call i32 @buyProduct(i32 3, %struct.Categories** %1)
%16 = load %struct.Categories*, %struct.Categories** %1
%17 = call i32 @printStore(%struct.Categories* %16)
%18 = call i32 @buyProduct(i32 4, %struct.Categories** %1)
%19 = load %struct.Categories*, %struct.Categories** %1
%20 = call i32 @printStore(%struct.Categories* %19)
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"
@__const.test3.names = [3 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)]
@.str.3 = [16 x i8] c"Canon SD1300 IS\00"
@.str.4 = [7 x i8] c"Amazon\00"
@.str.5 = [17 x i8] c"Programming in C\00"
@.str.6 = [14 x i8] c"ABC-Bookstore\00"
@.str.7 = [13 x i8] c"IPOD Shuffle\00"
@.str.8 = [6 x i8] c"Apple\00"
@.str.9 = [14 x i8] c"Amazon Kindle\00"
define void @test3() {
%1 = alloca %struct.Categories*
%2 = alloca [3 x i8*]
%3 = bitcast %struct.Categories** %1 to i8*
store %struct.Categories* null, %struct.Categories** %1
%4 = bitcast [3 x i8*]* %2 to i8*
%5 = call i32 @buyProduct(i32 3, %struct.Categories** %1)
%6 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 0
%7 = call i32 @addProduct(%struct.Categories** %1, i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double 2.290000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 1, i8** %6)
%8 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 1
%9 = call i32 @addProduct(%struct.Categories** %1, i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double 6.000000e+01, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 1, i8** %8)
%10 = call i32 @addProduct(%struct.Categories** %1, i32 3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), double 4.900000e+01, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 1, i8** %6)
%11 = call i32 @addProduct(%struct.Categories** %1, i32 4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), double 1.390000e+02, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 2, i8** %6)
%12 = call i32 @buyProduct(i32 8, %struct.Categories** %1)
%13 = call i32 @buyProduct(i32 3, %struct.Categories** %1)
%14 = load %struct.Categories*, %struct.Categories** %1
%15 = call i32 @printStore(%struct.Categories* %14)
%16 = call i32 @buyProduct(i32 4, %struct.Categories** %1)
%17 = load %struct.Categories*, %struct.Categories** %1
%18 = call i32 @printStore(%struct.Categories* %17)
ret void
}