#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*/ addArray(unsigned int *, unsigned int *);
int /*<<< orphan*/ initialize_temp(unsigned int *, unsigned int *);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ shift_bits(unsigned int *, unsigned int);
unsigned int multiply(unsigned int *a, unsigned int *b, unsigned int *c) {
  unsigned int temp[15];
  unsigned int k = 0, i, one = 1;
  int index;
  for (index = 4; index >= 0; index--) {
    printf("\nChecking b[%d]", index);
    for (i = 0; i < 32; i++, k++) {
      initialize_temp(a, temp);
      if ((one << i) & (b[index])) {
        printf("\n %dth bit is 1", k);
        shift_bits(temp, k);
        addArray(c, temp);
      }
    }
  }
}


x86 assembly (clang, -O0):
<multiply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x1,-0x6c(%rbp)
movl   $0x4,-0x70(%rbp)
cmpl   $0x0,-0x70(%rbp)
jl     1213 <multiply+0xd3>
mov    -0x70(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x68(%rbp)
cmpl   $0x20,-0x68(%rbp)
jae    1200 <multiply+0xc0>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1050 <initialize_temp@plt>
mov    -0x6c(%rbp),%eax
mov    -0x68(%rbp),%ecx
shl    %cl,%eax
mov    -0x18(%rbp),%rcx
movslq -0x70(%rbp),%rdx
and    (%rcx,%rdx,4),%eax
cmp    $0x0,%eax
je     11e4 <multiply+0xa4>
mov    -0x64(%rbp),%esi
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1060 <shift_bits@plt>
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <addArray@plt>
jmp    11e9 <multiply+0xa9>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1189 <multiply+0x49>
jmp    1205 <multiply+0xc5>
mov    -0x70(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x70(%rbp)
jmp    1169 <multiply+0x29>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multiply>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xea2(%rip),%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
xor    %ebp,%ebp
mov    %rsp,%r12
lea    0xe9c(%rip),%r13
jmp    1188 <multiply+0x48>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x20,%ebp
je     11bd <multiply+0x7d>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <initialize_temp@plt>
mov    0x10(%r15),%eax
bt     %ebp,%eax
jae    1180 <multiply+0x40>
mov    %r13,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1060 <shift_bits@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <addArray@plt>
jmp    1180 <multiply+0x40>
lea    0xe3c(%rip),%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
xor    %r13d,%r13d
mov    %rsp,%r12
jmp    11ea <multiply+0xaa>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    $0x20,%r13d
je     1228 <multiply+0xe8>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <initialize_temp@plt>
mov    0xc(%r15),%eax
bt     %r13d,%eax
jae    11e0 <multiply+0xa0>
lea    0x20(%r13),%ebp
lea    0xe06(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1060 <shift_bits@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <addArray@plt>
jmp    11e0 <multiply+0xa0>
lea    0xdd1(%rip),%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
xor    %r13d,%r13d
mov    %rsp,%r12
jmp    125a <multiply+0x11a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    $0x20,%r13d
je     1298 <multiply+0x158>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <initialize_temp@plt>
mov    0x8(%r15),%eax
bt     %r13d,%eax
jae    1250 <multiply+0x110>
lea    0x40(%r13),%ebp
lea    0xd96(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1060 <shift_bits@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <addArray@plt>
jmp    1250 <multiply+0x110>
lea    0xd61(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
xor    %r13d,%r13d
mov    %rsp,%r12
jmp    12ca <multiply+0x18a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    $0x20,%r13d
je     1308 <multiply+0x1c8>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <initialize_temp@plt>
mov    0x4(%r15),%eax
bt     %r13d,%eax
jae    12c0 <multiply+0x180>
lea    0x60(%r13),%ebp
lea    0xd26(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1060 <shift_bits@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <addArray@plt>
jmp    12c0 <multiply+0x180>
lea    0xcf1(%rip),%rdi
xor    %r13d,%r13d
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rsp,%r12
jmp    132a <multiply+0x1ea>
xchg   %ax,%ax
add    $0x1,%r13d
cmp    $0x20,%r13d
je     136a <multiply+0x22a>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <initialize_temp@plt>
mov    (%r15),%eax
bt     %r13d,%eax
jae    1320 <multiply+0x1e0>
lea    0x80(%r13),%ebp
lea    0xcc4(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1060 <shift_bits@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <addArray@plt>
jmp    1320 <multiply+0x1e0>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\0AChecking b[%d]\00"
@.str.1 = [16 x i8] c"\0A %dth bit is 1\00"
define i32 @multiply(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [15 x i32]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 0, i32* %9
store i32 1, i32* %11
store i32 4, i32* %12
br label %13
13: ; preds = %52, %3
%14 = load i32, i32* %12
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %55
16: ; preds = %13
%17 = load i32, i32* %12
%18 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %17)
store i32 0, i32* %10
br label %19
19: ; preds = %46, %16
%20 = load i32, i32* %10
%21 = icmp ult i32 %20, 32
br i1 %21, label %22, label %51
22: ; preds = %19
%23 = load i32*, i32** %5
%24 = getelementptr inbounds [15 x i32], [15 x i32]* %8, i64 0, i64 0
%25 = call i32 @initialize_temp(i32* %23, i32* %24)
%26 = load i32, i32* %11
%27 = load i32, i32* %10
%28 = shl i32 %26, %27
%29 = load i32*, i32** %6
%30 = load i32, i32* %12
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = and i32 %28, %33
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %45
36: ; preds = %22
%37 = load i32, i32* %9
%38 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [15 x i32], [15 x i32]* %8, i64 0, i64 0
%40 = load i32, i32* %9
%41 = call i32 @shift_bits(i32* %39, i32 %40)
%42 = load i32*, i32** %7
%43 = getelementptr inbounds [15 x i32], [15 x i32]* %8, i64 0, i64 0
%44 = call i32 @addArray(i32* %42, i32* %43)
br label %45
45: ; preds = %36, %22
br label %46
46: ; preds = %45
%47 = load i32, i32* %10
%48 = add i32 %47, 1
store i32 %48, i32* %10
%49 = load i32, i32* %9
%50 = add i32 %49, 1
store i32 %50, i32* %9
br label %19
51: ; preds = %19
br label %52
52: ; preds = %51
%53 = load i32, i32* %12
%54 = add nsw i32 %53, -1
store i32 %54, i32* %12
br label %13
55: ; preds = %13
%56 = load i32, i32* %4
ret i32 %56
}

LLVM IR (-O2):
@.str = [16 x i8] c"\0AChecking b[%d]\00"
@.str.1 = [16 x i8] c"\0A %dth bit is 1\00"
define i32 @multiply(i32* %0, i32* nocapture %1, i32* %2) {
%4 = alloca [15 x i32]
%5 = bitcast [15 x i32]* %4 to i8*
%6 = getelementptr inbounds [15 x i32], [15 x i32]* %4, i64 0, i64 0
%7 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 4)
%8 = getelementptr inbounds i32, i32* %1, i64 4
br label %9
9: ; preds = %3, %20
%10 = phi i32 [ 0, %3 ], [ %21, %20 ]
%11 = call i32 @initialize_temp(i32* %0, i32* %6)
%12 = shl nuw i32 1, %10
%13 = load i32, i32* %8
%14 = and i32 %13, %12
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %9
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%18 = call i32 @shift_bits(i32* %6, i32 %10)
%19 = call i32 @addArray(i32* %2, i32* %6)
br label %20
20: ; preds = %9, %16
%21 = add nuw nsw i32 %10, 1
%22 = icmp eq i32 %21, 32
br i1 %22, label %23, label %9
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 3)
%25 = getelementptr inbounds i32, i32* %1, i64 3
br label %26
26: ; preds = %38, %23
%27 = phi i32 [ 32, %23 ], [ %40, %38 ]
%28 = phi i32 [ 0, %23 ], [ %39, %38 ]
%29 = call i32 @initialize_temp(i32* %0, i32* %6)
%30 = shl nuw i32 1, %28
%31 = load i32, i32* %25
%32 = and i32 %31, %30
%33 = icmp eq i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %26
%35 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%36 = call i32 @shift_bits(i32* %6, i32 %27)
%37 = call i32 @addArray(i32* %2, i32* %6)
br label %38
38: ; preds = %34, %26
%39 = add nuw nsw i32 %28, 1
%40 = add nuw nsw i32 %27, 1
%41 = icmp eq i32 %39, 32
br i1 %41, label %42, label %26
42: ; preds = %38
%43 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 2)
%44 = getelementptr inbounds i32, i32* %1, i64 2
br label %45
45: ; preds = %57, %42
%46 = phi i32 [ 64, %42 ], [ %59, %57 ]
%47 = phi i32 [ 0, %42 ], [ %58, %57 ]
%48 = call i32 @initialize_temp(i32* %0, i32* %6)
%49 = shl nuw i32 1, %47
%50 = load i32, i32* %44
%51 = and i32 %50, %49
%52 = icmp eq i32 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %45
%54 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%55 = call i32 @shift_bits(i32* %6, i32 %46)
%56 = call i32 @addArray(i32* %2, i32* %6)
br label %57
57: ; preds = %53, %45
%58 = add nuw nsw i32 %47, 1
%59 = add nuw nsw i32 %46, 1
%60 = icmp eq i32 %58, 32
br i1 %60, label %61, label %45
61: ; preds = %57
%62 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 1)
%63 = getelementptr inbounds i32, i32* %1, i64 1
br label %64
64: ; preds = %76, %61
%65 = phi i32 [ 96, %61 ], [ %78, %76 ]
%66 = phi i32 [ 0, %61 ], [ %77, %76 ]
%67 = call i32 @initialize_temp(i32* %0, i32* %6)
%68 = shl nuw i32 1, %66
%69 = load i32, i32* %63
%70 = and i32 %69, %68
%71 = icmp eq i32 %70, 0
br i1 %71, label %76, label %72
72: ; preds = %64
%73 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %65)
%74 = call i32 @shift_bits(i32* %6, i32 %65)
%75 = call i32 @addArray(i32* %2, i32* %6)
br label %76
76: ; preds = %72, %64
%77 = add nuw nsw i32 %66, 1
%78 = add nuw nsw i32 %65, 1
%79 = icmp eq i32 %77, 32
br i1 %79, label %80, label %64
80: ; preds = %76
%81 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 0)
br label %82
82: ; preds = %94, %80
%83 = phi i32 [ 128, %80 ], [ %96, %94 ]
%84 = phi i32 [ 0, %80 ], [ %95, %94 ]
%85 = call i32 @initialize_temp(i32* %0, i32* %6)
%86 = shl nuw i32 1, %84
%87 = load i32, i32* %1
%88 = and i32 %87, %86
%89 = icmp eq i32 %88, 0
br i1 %89, label %94, label %90
90: ; preds = %82
%91 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %83)
%92 = call i32 @shift_bits(i32* %6, i32 %83)
%93 = call i32 @addArray(i32* %2, i32* %6)
br label %94
94: ; preds = %90, %82
%95 = add nuw nsw i32 %84, 1
%96 = add nuw nsw i32 %83, 1
%97 = icmp eq i32 %95, 32
br i1 %97, label %98, label %82
98: ; preds = %94
ret i32 undef
}