#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ transMacStrToCfg(char *, int, char *, int);
int main() {
  int strlenlimit = 1024;
  int macMaxCnt = 5;
  char *strPtr;
  char *cfgPtr;
  strPtr = malloc(strlenlimit);
  cfgPtr = malloc(strlenlimit);
  printf("input mac:\n");
  scanf("%s", strPtr);
  transMacStrToCfg(cfgPtr, macMaxCnt, strPtr, strlenlimit);
  printf("cfgPtr:%s\nstrPtr:%s\n", cfgPtr, strPtr);
  free(strPtr);
  free(cfgPtr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x400,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%ecx
call   1040 <transMacStrToCfg@plt>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xe93(%rip),%rdi
call   1050 <puts@plt>
lea    0xe6f(%rip),%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    %rbx,%rdx
mov    $0x400,%ecx
call   1040 <transMacStrToCfg@plt>
lea    0xe4e(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"input mac:\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [21 x i8] c"cfgPtr:%s\0AstrPtr:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
store i32 1024, i32* %2
store i32 5, i32* %3
%6 = load i32, i32* %2
%7 = call i8* @malloc(i32 %6)
store i8* %7, i8** %4
%8 = load i32, i32* %2
%9 = call i8* @malloc(i32 %8)
store i8* %9, i8** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %4
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %5
%14 = load i32, i32* %3
%15 = load i8*, i8** %4
%16 = load i32, i32* %2
%17 = call i32 @transMacStrToCfg(i8* %13, i32 %14, i8* %15, i32 %16)
%18 = load i8*, i8** %5
%19 = load i8*, i8** %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %19)
%21 = load i8*, i8** %4
%22 = call i32 @free(i8* %21)
%23 = load i8*, i8** %5
%24 = call i32 @free(i8* %23)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [21 x i8] c"cfgPtr:%s\0AstrPtr:%s\0A\00"
@str = [11 x i8] c"input mac:\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%2 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%5 = tail call i32 @transMacStrToCfg(i8* %2, i32 5, i8* %1, i32 1024)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %1)
%7 = tail call i32 @free(i8* %1)
%8 = tail call i32 @free(i8* %2)
ret i32 0
}