#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char const *, long const);
int /*<<< orphan*/ stderr;
char *strerror(int);
int usage(const char *cn, const long max, FILE *f) {
  if (errno)
    fprintf(stderr, "Error: %s\n", strerror(errno));
  printf("Usage: %s [[0-%ld]|[[+|-]0-100%%]|max]\n", cn, max);
  fclose(f);
  return errno;
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e7d(%rip),%rax
cmpl   $0x0,(%rax)
je     1190 <usage+0x50>
mov    0x2e75(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe75(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x2e80(%rip),%r12
mov    (%r12),%edi
test   %edi,%edi
je     117f <usage+0x3f>
mov    0x2e79(%rip),%rax
mov    (%rax),%ebp
call   1060 <strerror@plt>
lea    0xe8b(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
lea    0xe85(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    (%r12),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
@stderr = global i32 0
@.str = [11 x i8] c"Error: %s\0A\00"
@.str.1 = [40 x i8] c"Usage: %s [[0-%ld]|[[+|-]0-100%%]|max]\0A\00"
define i32 @usage(i8* %0, i64 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32*
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32* %2, i32** %6
%7 = load i32, i32* @errno
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = call i8* @strerror(i32 %11)
%13 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %9, %3
%15 = load i8*, i8** %4
%16 = load i64, i64* %5
%17 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %15, i64 %16)
%18 = load i32*, i32** %6
%19 = call i32 @fclose(i32* %18)
%20 = load i32, i32* @errno
ret i32 %20
}

LLVM IR (-O2):
@errno = global i32 0
@stderr = global i32 0
@.str = [11 x i8] c"Error: %s\0A\00"
@.str.1 = [40 x i8] c"Usage: %s [[0-%ld]|[[+|-]0-100%%]|max]\0A\00"
define i32 @usage(i8* %0, i64 %1, i32* nocapture %2) {
%4 = load i32, i32* @errno
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i8* @strerror(i32 %4)
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %6, %3
%11 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %0, i64 %1)
%12 = tail call i32 @fclose(i32* %2)
%13 = load i32, i32* @errno
ret i32 %13
}