#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 */
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int atoi(char *);
char *generate_mac(char *, int, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  char buffer[64];
  assert(1 < argc);
  int local_addr = atoi(argv[1]);
  int format_addr = atoi(argv[2]);
  int case_addr = atoi(argv[3]);
  int count_addr = atoi(argv[4]);
  int i;
  for (i = 0; i < count_addr; i++) {
    printf("%s", generate_mac(buffer, sizeof(buffer), local_addr,
                              format_addr - 1, case_addr));
    if (i < count_addr - 1) {
      printf("\n");
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x60(%rbp),%eax
jge    121c <main+0xdc>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%edx
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x5c(%rbp),%r8d
mov    $0x40,%esi
call   1050 <generate_mac@plt>
mov    %rax,%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x64(%rbp),%eax
mov    -0x60(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1209 <main+0xc9>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120e <main+0xce>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11b2 <main+0x72>
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbp
xor    %eax,%eax
cmp    $0x2,%edi
setge  %al
mov    %eax,%edi
call   1050 <assert@plt>
mov    0x8(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
mov    0x20(%rbp),%rdi
call   1070 <atoi@plt>
test   %eax,%eax
jle    11f0 <main+0xa0>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
add    $0xffffffff,%ebp
lea    -0x1(%rbx),%r12d
xor    %r13d,%r13d
jmp    11b9 <main+0x69>
xchg   %ax,%ax
add    $0x1,%r13d
cmp    %r13d,%ebx
je     11f0 <main+0xa0>
mov    %rsp,%rdi
mov    $0x40,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %r15d,%r8d
call   1060 <generate_mac@plt>
lea    0xe2b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12d,%r13d
jge    11b0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11b0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 4
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %34
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = add nsw i32 %21, -1
%23 = add nsw i32 %16, -1
br label %24
24: ; preds = %18, %31
%25 = phi i32 [ 0, %18 ], [ %32, %31 ]
%26 = call i8* @generate_mac(i8* %4, i32 64, i32 %10, i32 %22, i32 %13)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = icmp slt i32 %25, %23
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 @putchar(i32 10)
br label %31
31: ; preds = %24, %29
%32 = add nuw nsw i32 %25, 1
%33 = icmp eq i32 %32, %16
br i1 %33, label %34, label %24
34: ; preds = %31, %2
%35 = call i32 @putchar(i32 10)
ret i32 0
}