#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 *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int);
int main(int argc, char *argv[]) {
  char *dna = (char *)malloc(4 * sizeof(char *));
  dna[0] = 'A';
  dna[1] = 'C';
  dna[2] = 'G';
  dna[3] = 'T';
  if (argc < 3) {
    printf("Usage: $s characters seed");
    return 0;
  }
  int chars = atoi(argv[1]);
  int seed = atoi(argv[2]);
  int i;
  srand(seed);
  for (i = 0; i < chars; i++) {
    printf("%c", dna[rand() % 4]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x41,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x43,0x1(%rax)
mov    -0x18(%rbp),%rax
movb   $0x47,0x2(%rax)
mov    -0x18(%rbp),%rax
movb   $0x54,0x3(%rax)
cmpl   $0x3,-0x8(%rbp)
jge    11b7 <main+0x67>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1237 <main+0xe7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1040 <srand@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1230 <main+0xe0>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e6 <main+0x96>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    $0x20,%edi
call   1060 <malloc@plt>
movl   $0x54474341,(%rax)
cmp    $0x2,%ebp
jg     118e <main+0x2e>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d4 <main+0x74>
mov    %rax,%rbx
mov    0x8(%r14),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%r14),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
call   1050 <srand@plt>
test   %ebp,%ebp
jle    11d4 <main+0x74>
xor    %eax,%eax
call   1080 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
cltq
movsbl (%rbx,%rax,1),%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [26 x i8] c"Usage: $s characters seed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i64 @malloc(i32 32)
%4 = inttoptr i64 %3 to i8*
store i8 65, i8* %4
%5 = getelementptr inbounds i8, i8* %4, i64 1
store i8 67, i8* %5
%6 = getelementptr inbounds i8, i8* %4, i64 2
store i8 71, i8* %6
%7 = getelementptr inbounds i8, i8* %4, i64 3
store i8 84, i8* %7
%8 = icmp slt i32 %0, 3
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %31
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = tail call i32 @srand(i32 %17)
%19 = icmp sgt i32 %14, 0
br i1 %19, label %20, label %31
20: ; preds = %11, %20
%21 = phi i32 [ %29, %20 ], [ 0, %11 ]
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %4, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = tail call i32 @putchar(i32 %27)
%29 = add nuw nsw i32 %21, 1
%30 = icmp eq i32 %29, %14
br i1 %30, label %31, label %20
31: ; preds = %20, %11, %9
ret i32 0
}