#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ swap_mac_addr(void *);
int main() {
  char *s = (char *)malloc(sizeof(char) * 12);
  for (int i = 0; i < 12; i++)
    s[i] = i + 1;
  for (int i = 0; i < 12; i++)
    printf("%x ", s[i]);
  swap_mac_addr((void *)s);
  for (int i = 0; i < 12; i++)
    printf("%x ", s[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jge    117f <main+0x4f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <main+0x24>
movl   $0x0,-0x18(%rbp)
cmpl   $0xc,-0x18(%rbp)
jge    11b6 <main+0x86>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
lea    0xe61(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1186 <main+0x56>
mov    -0x10(%rbp),%rdi
call   1050 <swap_mac_addr@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xc,-0x1c(%rbp)
jge    11f6 <main+0xc6>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
lea    0xe21(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c6 <main+0x96>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
movabs $0x807060504030201,%rax
06 07 08
mov    %rax,(%rbx)
movl   $0xc0b0a09,0x8(%rbx)
lea    0xea4(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
movsbl 0x1(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x2(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x3(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x4(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x5(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x6(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x7(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x8(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x9(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0xa(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0xb(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <swap_mac_addr@plt>
movsbl (%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x1(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x2(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x3(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x4(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x5(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x6(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x7(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x8(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0x9(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0xa(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
movsbl 0xb(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%x \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i64 @malloc(i32 12)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %2
store i32 0, i32* %3
br label %8
8: ; preds = %19, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 12
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
%14 = trunc i32 %13 to i8
%15 = load i8*, i8** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
store i8 %14, i8* %18
br label %19
19: ; preds = %11
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %8
22: ; preds = %8
store i32 0, i32* %4
br label %23
23: ; preds = %33, %22
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 12
br i1 %25, label %26, label %36
26: ; preds = %23
%27 = load i8*, i8** %2
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %31)
br label %33
33: ; preds = %26
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %23
36: ; preds = %23
%37 = load i8*, i8** %2
%38 = call i32 @swap_mac_addr(i8* %37)
store i32 0, i32* %5
br label %39
39: ; preds = %49, %36
%40 = load i32, i32* %5
%41 = icmp slt i32 %40, 12
br i1 %41, label %42, label %52
42: ; preds = %39
%43 = load i8*, i8** %2
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %47)
br label %49
49: ; preds = %42
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
br label %39
52: ; preds = %39
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%x \00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 12)
%2 = inttoptr i64 %1 to i8*
store i8 1, i8* %2
%3 = getelementptr inbounds i8, i8* %2, i64 1
store i8 2, i8* %3
%4 = getelementptr inbounds i8, i8* %2, i64 2
store i8 3, i8* %4
%5 = getelementptr inbounds i8, i8* %2, i64 3
store i8 4, i8* %5
%6 = getelementptr inbounds i8, i8* %2, i64 4
store i8 5, i8* %6
%7 = getelementptr inbounds i8, i8* %2, i64 5
store i8 6, i8* %7
%8 = getelementptr inbounds i8, i8* %2, i64 6
store i8 7, i8* %8
%9 = getelementptr inbounds i8, i8* %2, i64 7
store i8 8, i8* %9
%10 = getelementptr inbounds i8, i8* %2, i64 8
store i8 9, i8* %10
%11 = getelementptr inbounds i8, i8* %2, i64 9
store i8 10, i8* %11
%12 = getelementptr inbounds i8, i8* %2, i64 10
store i8 11, i8* %12
%13 = getelementptr inbounds i8, i8* %2, i64 11
store i8 12, i8* %13
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext 1)
%15 = load i8, i8* %3
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %15)
%17 = load i8, i8* %4
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %17)
%19 = load i8, i8* %5
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %19)
%21 = load i8, i8* %6
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %21)
%23 = load i8, i8* %7
%24 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %23)
%25 = load i8, i8* %8
%26 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %25)
%27 = load i8, i8* %9
%28 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %27)
%29 = load i8, i8* %10
%30 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %29)
%31 = load i8, i8* %11
%32 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %31)
%33 = load i8, i8* %12
%34 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %33)
%35 = load i8, i8* %13
%36 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %35)
%37 = tail call i32 @swap_mac_addr(i8* %2)
%38 = load i8, i8* %2
%39 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %38)
%40 = load i8, i8* %3
%41 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %40)
%42 = load i8, i8* %4
%43 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %42)
%44 = load i8, i8* %5
%45 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %44)
%46 = load i8, i8* %6
%47 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %46)
%48 = load i8, i8* %7
%49 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %48)
%50 = load i8, i8* %8
%51 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %50)
%52 = load i8, i8* %9
%53 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %52)
%54 = load i8, i8* %10
%55 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %54)
%56 = load i8, i8* %11
%57 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %56)
%58 = load i8, i8* %12
%59 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %58)
%60 = load i8, i8* %13
%61 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %60)
ret i32 0
}