#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*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  unsigned short s;
  int i;
  char buf[80];
  if (argc < 3) {
    return -1;
  }
  i = atoi(argv[1]);
  s = i;
  if (s >= 80) {
    printf("Oh no you don't!\n");
    return -1;
  }
  printf("s = %d\n", s);
  memcpy(buf, argv[2], i);
  buf[i] = '\0';
  printf("%s\n", buf);
  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)
cmpl   $0x3,-0x8(%rbp)
jge    115c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e2 <main+0xb2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %ax,-0x12(%rbp)
movzwl -0x12(%rbp),%eax
cmp    $0x50,%eax
jl     119a <main+0x6a>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e2 <main+0xb2>
movzwl -0x12(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x18(%rbp),%edx
call   1040 <memcpy@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    $0xffffffff,%ebp
cmp    $0x3,%edi
jl     11a4 <main+0x64>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
movzwl %r14w,%esi
cmp    $0x50,%esi
jb     1173 <main+0x33>
lea    0xe97(%rip),%rdi
jmp    119f <main+0x5f>
lea    0xe86(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14d,%edx
call   1050 <memcpy@plt>
movslq %r14d,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Oh no you don't!\0A\00"
@.str.1 = [8 x i8] c"s = %d\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16
%7 = alloca i32
%8 = alloca [80 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %39
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = trunc i32 %17 to i16
store i16 %18, i16* %6
%19 = load i16, i16* %6
%20 = zext i16 %19 to i32
%21 = icmp sge i32 %20, 80
br i1 %21, label %22, label %24
22: ; preds = %12
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %39
24: ; preds = %12
%25 = load i16, i16* %6
%26 = zext i16 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = load i32, i32* %7
%33 = call i32 @memcpy(i8* %28, i8* %31, i32 %32)
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 %35
store i8 0, i8* %36
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %37)
store i32 0, i32* %3
br label %39
39: ; preds = %24, %22, %11
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"s = %d\0A\00"
@str = [17 x i8] c"Oh no you don't!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 3
br i1 %5, label %22, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = and i32 %9, 65535
%11 = icmp ugt i32 %10, 79
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %22
14: ; preds = %6
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @memcpy(i8* %4, i8* %17, i32 %9)
%19 = sext i32 %9 to i64
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %19
store i8 0, i8* %20
%21 = call i32 @puts(i8* %4)
br label %22
22: ; preds = %2, %14, %12
%23 = phi i32 [ -1, %12 ], [ 0, %14 ], [ -1, %2 ]
ret i32 %23
}