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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ _snprintf(char *, int, char *, ...);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int sscanf(char *, char *, int *, int *, int *);
int /*<<< orphan*/ stderr;
scalar_t__ system(char *);
int main(int argc, char *argv[]) {
  char *prog, *arch, *def, *version, *lib;
  char s[1024];
  char name[16];
  int current, age, revision;
  if (argc != 6) {
    fprintf(stderr, "bad number of arguments");
    exit(EXIT_FAILURE);
  }
  prog = argv[1];
  arch = argv[2];
  def = argv[3];
  version = argv[4];
  lib = argv[5];
  if (sscanf(version, "%d:%d:%d", &current, &revision, &age) != 3)
    exit(EXIT_FAILURE);
  _snprintf(name, sizeof(name), "libhwloc-%d", current - age);
  printf("using soname %s\n", name);
  _snprintf(s, sizeof(s), "\"%s\" /machine:%s /def:%s /name:%s /out:%s", prog,
            arch, def, name, lib);
  if (system(s)) {
    fprintf(stderr, "%s failed\n", s);
    exit(EXIT_FAILURE);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x6,-0x8(%rbp)
je     11a8 <main+0x48>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe29(%rip),%rsi
lea    -0x454(%rbp),%rdx
lea    -0x45c(%rbp),%rcx
lea    -0x458(%rbp),%r8
call   1060 <sscanf@plt>
cmp    $0x3,%eax
je     1220 <main+0xc0>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x450(%rbp),%rdi
mov    -0x454(%rbp),%ecx
sub    -0x458(%rbp),%ecx
mov    $0x10,%esi
lea    0xde2(%rip),%rdx
mov    $0x0,%al
call   1070 <_snprintf@plt>
lea    -0x450(%rbp),%rsi
lea    0xdd9(%rip),%rdi
call   1040 <printf@plt>
lea    -0x440(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
lea    -0x450(%rbp),%r10
mov    -0x38(%rbp),%rax
mov    $0x400,%esi
lea    0xdbb(%rip),%rdx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1070 <_snprintf@plt>
lea    -0x440(%rbp),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     12d5 <main+0x175>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
lea    -0x440(%rbp),%rdx
lea    0xda8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
cmp    $0x6,%edi
jne    122a <main+0xca>
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r14
mov    0x18(%rsi),%r15
mov    0x20(%rsi),%rdi
mov    0x28(%rsi),%rbp
lea    0xe83(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x4(%rsp),%r8
call   1060 <sscanf@plt>
cmp    $0x3,%eax
jne    125f <main+0xff>
mov    0x8(%rsp),%ecx
sub    0x4(%rsp),%ecx
lea    0xe60(%rip),%rdx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1070 <_snprintf@plt>
lea    0xe51(%rip),%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
lea    0xe53(%rip),%rdx
lea    0x20(%rsp),%r13
mov    %r13,%rdi
mov    $0x400,%esi
mov    %rbx,%rcx
mov    %r14,%r8
mov    %r15,%r9
xor    %eax,%eax
push   %rbp
push   %r12
call   1070 <_snprintf@plt>
add    $0x10,%rsp
mov    %r13,%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    1243 <main+0xe3>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
lea    0xdc6(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    125f <main+0xff>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"bad number of arguments\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"%d:%d:%d\00"
@.str.2 = [12 x i8] c"libhwloc-%d\00"
@.str.3 = [17 x i8] c"using soname %s\0A\00"
@.str.4 = [42 x i8] c"\22%s\22 /machine:%s /def:%s /name:%s /out:%s\00"
@.str.5 = [11 x i8] c"%s failed\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [1024 x i8]
%12 = alloca [16 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 6
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %6
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
store i8* %29, i8** %7
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
store i8* %32, i8** %8
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 4
%35 = load i8*, i8** %34
store i8* %35, i8** %9
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 5
%38 = load i8*, i8** %37
store i8* %38, i8** %10
%39 = load i8*, i8** %9
%40 = call i32 @sscanf(i8* %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %13, i32* %15, i32* %14)
%41 = icmp ne i32 %40, 3
br i1 %41, label %42, label %45
42: ; preds = %23
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %23
%46 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%47 = load i32, i32* %13
%48 = load i32, i32* %14
%49 = sub nsw i32 %47, %48
%50 = call i32 (i8*, i32, i8*, ...) @_snprintf(i8* %46, i32 16, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%52 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %51)
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%54 = load i8*, i8** %6
%55 = load i8*, i8** %7
%56 = load i8*, i8** %8
%57 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%58 = load i8*, i8** %10
%59 = call i32 (i8*, i32, i8*, ...) @_snprintf(i8* %53, i32 1024, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %54, i8* %55, i8* %56, i8* %57, i8* %58)
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%61 = call i64 @system(i8* %60)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %45
%64 = load i32, i32* @stderr
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %65)
%67 = load i32, i32* @EXIT_FAILURE
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %45
%70 = load i32, i32* @EXIT_SUCCESS
%71 = call i32 @exit(i32 %70)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"bad number of arguments\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"%d:%d:%d\00"
@.str.2 = [12 x i8] c"libhwloc-%d\00"
@.str.3 = [17 x i8] c"using soname %s\0A\00"
@.str.4 = [42 x i8] c"\22%s\22 /machine:%s /def:%s /name:%s /out:%s\00"
@.str.5 = [11 x i8] c"%s failed\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [16 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = icmp eq i32 %0, 6
br i1 %13, label %19, label %14
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = tail call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8*, i8** %1, i64 3
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8*, i8** %1, i64 4
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8*, i8** %1, i64 5
%29 = load i8*, i8** %28
%30 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %7, i32* %6)
%31 = icmp eq i32 %30, 3
br i1 %31, label %35, label %32
32: ; preds = %19
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %19
%36 = load i32, i32* %5
%37 = load i32, i32* %6
%38 = sub nsw i32 %36, %37
%39 = call i32 (i8*, i32, i8*, ...) @_snprintf(i8* %9, i32 16, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%41 = call i32 (i8*, i32, i8*, ...) @_snprintf(i8* %8, i32 1024, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %21, i8* %23, i8* %25, i8* %9, i8* %29)
%42 = call i64 @system(i8* %8)
%43 = icmp eq i64 %42, 0
br i1 %43, label %49, label %44
44: ; preds = %35
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %8)
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %35
%50 = load i32, i32* @EXIT_SUCCESS
%51 = call i32 @exit(i32 %50)
unreachable
}