main(argc, argv) char **argv;
{
  int c, n;
  char *s;
  n = 0;
  if (argc < 2) {
    printf("arg count\n");
    exit(0);
  }
  s = argv[1];
  while (c = *s++) {
    if (c < '0' || c > '9') {
      printf("bad character\n");
      exit(0);
    }
    n = n * 10 + c - '0';
  }
  sleep(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,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    116c <main+0x3c>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11d1 <main+0xa1>
cmpl   $0x30,-0x14(%rbp)
jl     11aa <main+0x7a>
cmpl   $0x39,-0x14(%rbp)
jle    11bf <main+0x8f>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
imul   $0xa,-0x18(%rbp),%eax
add    -0x14(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x18(%rbp)
jmp    1178 <main+0x48>
mov    -0x18(%rbp),%edi
mov    $0x0,%al
call   1050 <sleep@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x1,%edi
jle    1191 <main+0x61>
mov    0x8(%rsi),%rax
mov    (%rax),%cl
test   %cl,%cl
je     1171 <main+0x41>
add    $0x1,%rax
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
lea    -0x3a(%rcx),%edx
cmp    $0xf5,%dl
jbe    117e <main+0x4e>
movzbl %cl,%ecx
lea    (%rdi,%rdi,4),%edx
lea    (%rcx,%rdx,2),%edi
add    $0xffffffd0,%edi
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1150 <main+0x20>
jmp    1173 <main+0x43>
xor    %edi,%edi
xor    %eax,%eax
call   1050 <sleep@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <exit@plt>
lea    0xe76(%rip),%rdi
jmp    1185 <main+0x55>

LLVM IR (-O0):
@.str = [11 x i8] c"arg count\0A\00"
@.str.1 = [15 x i8] c"bad character\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* %7
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %8
br label %17
17: ; preds = %31, %13
%18 = load i8*, i8** %8
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %8
%20 = load i8, i8* %18
%21 = sext i8 %20 to i32
store i32 %21, i32* %6
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %37
23: ; preds = %17
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 48
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* %6
%28 = icmp sgt i32 %27, 57
br i1 %28, label %29, label %31
29: ; preds = %26, %23
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
unreachable
31: ; preds = %26
%32 = load i32, i32* %7
%33 = mul nsw i32 %32, 10
%34 = load i32, i32* %6
%35 = add nsw i32 %33, %34
%36 = sub nsw i32 %35, 48
store i32 %36, i32* %7
br label %17
37: ; preds = %17
%38 = load i32, i32* %7
%39 = call i32 (i32, ...) bitcast (i32 (...)* @sleep to i32 (i32, ...)*)(i32 %38)
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@str = [14 x i8] c"bad character\00"
@str.2 = [10 x i8] c"arg count\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.2, i64 0, i64 0))
tail call void @exit(i32 0)
unreachable
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %27, label %11
11: ; preds = %6, %20
%12 = phi i8 [ %25, %20 ], [ %9, %6 ]
%13 = phi i8* [ %15, %20 ], [ %8, %6 ]
%14 = phi i32 [ %24, %20 ], [ 0, %6 ]
%15 = getelementptr inbounds i8, i8* %13, i64 1
%16 = add i8 %12, -58
%17 = icmp ult i8 %16, -10
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
tail call void @exit(i32 0)
unreachable
20: ; preds = %11
%21 = zext i8 %12 to i32
%22 = mul nsw i32 %14, 10
%23 = add i32 %22, -48
%24 = add i32 %23, %21
%25 = load i8, i8* %15
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %11
27: ; preds = %20, %6
%28 = phi i32 [ 0, %6 ], [ %24, %20 ]
%29 = tail call i32 (i32, ...) bitcast (i32 (...)* @sleep to i32 (i32, ...)*)(i32 %28)
ret i32 0
}