#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int a = 0, l;
  char *c = argv[1];
  if (argc != 3 || !*c) {
    fprintf(stderr, "Usage: %s textkey [length]\n", argv[0]);
    exit(1);
  }
  l = atoi(argv[2]);
  while (l) {
    if (!*c)
      c = argv[1];
    printf("%02x", *c);
    c++;
    if (--l)
      printf(":");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1180 <main+0x40>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11a6 <main+0x66>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe69(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     121f <main+0xdf>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11d9 <main+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     121a <main+0xda>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b6 <main+0x76>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x3,%edi
jne    11f5 <main+0xa5>
mov    0x8(%r14),%r12
mov    (%r12),%r13b
test   %r13b,%r13b
je     11f5 <main+0xa5>
mov    0x10(%r14),%rdi
call   1060 <atoi@plt>
test   %eax,%eax
je     11da <main+0x8a>
mov    %eax,%ebp
add    $0xffffffff,%ebp
lea    0xe8b(%rip),%r15
test   %r13b,%r13b
jne    11a8 <main+0x58>
cs nopw 0x0(%rax,%rax,1)
mov    0x8(%r14),%r12
mov    (%r12),%r13b
movsbl %r13b,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
sub    $0x1,%ebp
jb     11da <main+0x8a>
lea    0x1(%r12),%rbx
mov    $0x3a,%edi
call   1030 <putchar@plt>
movzbl 0x1(%r12),%r13d
mov    %rbx,%r12
test   %r13b,%r13b
jne    11a8 <main+0x58>
jmp    11a0 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xdf8(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Usage: %s textkey [length]\0A\00"
@.str.1 = [5 x i8] c"%02x\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8, i8* %4
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %6, %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %6
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %38, label %19
19: ; preds = %14, %34
%20 = phi i8 [ %37, %34 ], [ %7, %14 ]
%21 = phi i8* [ %35, %34 ], [ %4, %14 ]
%22 = phi i32 [ %32, %34 ], [ %17, %14 ]
%23 = icmp eq i8 %20, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
br label %27
27: ; preds = %24, %19
%28 = phi i8 [ %20, %19 ], [ %26, %24 ]
%29 = phi i8* [ %21, %19 ], [ %25, %24 ]
%30 = sext i8 %28 to i32
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = add nsw i32 %22, -1
%33 = icmp eq i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %27
%35 = getelementptr inbounds i8, i8* %29, i64 1
%36 = tail call i32 @putchar(i32 58)
%37 = load i8, i8* %35
br label %19
38: ; preds = %27, %14
%39 = tail call i32 @putchar(i32 10)
ret i32 0
}