#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*/ kprintf(char *, ...);
int partC(int m) {
  unsigned int *mem;
  int o = 200;
  char p = 'a', q = 'A';
  kprintf("In c, called from b, called from a\r\n");
  kprintf("address of param m is 0x%x\r\n", (unsigned int)&m);
  kprintf("address of vars mem, o, p, q are 0x%x, 0x%x, 0x%x, 0x%x\r\n",
          (unsigned int)&mem, (unsigned int)&o, (unsigned int)&p,
          (unsigned int)&q);
  kprintf("Enter a memory location to start at.  Will print values in next 32 "
          "words.\r\n");
  int i;
  for (i = 0; i < 32; i++) {
    kprintf("At 0x%x, we see value 0x%08x\r\n", mem + i,
            (unsigned int)*(i + mem));
  }
  return 0;
}


x86 assembly (clang, -O0):
<partC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xc8,-0x14(%rbp)
movb   $0x61,-0x15(%rbp)
movb   $0x41,-0x16(%rbp)
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <kprintf@plt>
lea    -0x4(%rbp),%rax
mov    %eax,%esi
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <kprintf@plt>
lea    -0x10(%rbp),%rax
mov    %eax,%esi
lea    -0x14(%rbp),%rax
mov    %eax,%edx
lea    -0x15(%rbp),%rax
mov    %eax,%ecx
lea    -0x16(%rbp),%rax
mov    %eax,%r8d
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <kprintf@plt>
lea    0xf02(%rip),%rdi
mov    $0x0,%al
call   1030 <kprintf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x20,-0x1c(%rbp)
jge    11ca <partC+0xba>
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xf13(%rip),%rdi
mov    $0x0,%al
call   1030 <kprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1188 <partC+0x78>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<partC>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,0xc(%rsp)
movl   $0xc8,0x8(%rsp)
movb   $0x61,0x7(%rsp)
movb   $0x41,0x6(%rsp)
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1030 <kprintf@plt>
lea    0xc(%rsp),%rsi
lea    0xede(%rip),%rdi
xor    %eax,%eax
call   1030 <kprintf@plt>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x7(%rsp),%rcx
lea    0x6(%rsp),%r8
lea    0xed9(%rip),%rdi
xor    %eax,%eax
call   1030 <kprintf@plt>
lea    0xf05(%rip),%rdi
xor    %eax,%eax
call   1030 <kprintf@plt>
lea    0xf43(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rsi
mov    (%rsi,%rbx,1),%edx
add    %rbx,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <kprintf@plt>
add    $0x4,%rbx
cmp    $0x80,%rbx
jne    1190 <partC+0x80>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"In c, called from b, called from a\0D\0A\00"
@.str.1 = [29 x i8] c"address of param m is 0x%x\0D\0A\00"
@.str.2 = [58 x i8] c"address of vars mem, o, p, q are 0x%x, 0x%x, 0x%x, 0x%x\0D\0A\00"
@.str.3 = [76 x i8] c"Enter a memory location to start at. Will print values in next 32 words.\0D\0A\00"
@.str.4 = [31 x i8] c"At 0x%x, we see value 0x%08x\0D\0A\00"
define i32 @partC(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca i32
store i32 %0, i32* %2
store i32 200, i32* %4
store i8 97, i8* %5
store i8 65, i8* %6
%8 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%9 = ptrtoint i32* %2 to i32
%10 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = ptrtoint i32** %3 to i32
%12 = ptrtoint i32* %4 to i32
%13 = ptrtoint i8* %5 to i32
%14 = ptrtoint i8* %6 to i32
%15 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %12, i32 %13, i32 %14)
%16 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %17
17: ; preds = %31, %1
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 32
br i1 %19, label %20, label %34
20: ; preds = %17
%21 = load i32*, i32** %3
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %7
%26 = load i32*, i32** %3
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds i32, i32* %26, i64 %27
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32* %24, i32 %29)
br label %31
31: ; preds = %20
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %17
34: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"In c, called from b, called from a\0D\0A\00"
@.str.1 = [29 x i8] c"address of param m is 0x%x\0D\0A\00"
@.str.2 = [58 x i8] c"address of vars mem, o, p, q are 0x%x, 0x%x, 0x%x, 0x%x\0D\0A\00"
@.str.3 = [76 x i8] c"Enter a memory location to start at. Will print values in next 32 words.\0D\0A\00"
@.str.4 = [31 x i8] c"At 0x%x, we see value 0x%08x\0D\0A\00"
define i32 @partC(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
store i32 %0, i32* %2
%7 = bitcast i32** %3 to i8*
%8 = bitcast i32* %4 to i8*
store i32 200, i32* %4
store i8 97, i8* %5
store i8 65, i8* %6
%9 = tail call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%10 = ptrtoint i32* %2 to i64
%11 = trunc i64 %10 to i32
%12 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = ptrtoint i32** %3 to i64
%14 = trunc i64 %13 to i32
%15 = ptrtoint i32* %4 to i64
%16 = trunc i64 %15 to i32
%17 = ptrtoint i8* %5 to i64
%18 = trunc i64 %17 to i32
%19 = ptrtoint i8* %6 to i64
%20 = trunc i64 %19 to i32
%21 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %16, i32 %18, i32 %20)
%22 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %1, %23
%24 = phi i64 [ 0, %1 ], [ %29, %23 ]
%25 = load i32*, i32** %3
%26 = getelementptr inbounds i32, i32* %25, i64 %24
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @kprintf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32* %26, i32 %27)
%29 = add nuw nsw i64 %24, 1
%30 = icmp eq i64 %29, 32
br i1 %30, label %31, label %23
31: ; preds = %23
ret i32 0
}