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

/* Variables and functions */
int /*<<< orphan*/ bitfield_order(int /*<<< orphan*/ *);
int /*<<< orphan*/ byte_order(int /*<<< orphan*/ *);
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isalpha(char);
char *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stddefs(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ tolower(char);
int /*<<< orphan*/ word_sizes(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *f;
  char *path, *guard, *p;
  time_t tp;
  int i, len;
  if (argc != 2) {
    fprintf(stderr, "usage: machdep <outfile>\n");
    return 1;
  }
  path = argv[1];
  len = strlen(path);
  p = guard = malloc(len + 5);
  *p++ = '_';
  *p++ = '_';
  for (i = 0; i < len; ++i) {
    char c = path[i];
    if (isalpha(c)) {
      *p++ = tolower(c);
    } else {
      *p++ = '_';
    }
  }
  *p++ = '_';
  *p++ = '_';
  *p++ = '\0';
  if ((f = fopen(path, "w")) == NULL) {
    perror("fopen");
    return 1;
  }
  tp = time(NULL);
  fprintf(f, "/*\n");
  fprintf(f, " *\tmachdep.h generated by machdep at %s", ctime(&tp));
  fprintf(f, " */\n\n");
  fprintf(f, "#ifndef %s\n", guard);
  fprintf(f, "#define %s\n\n", guard);
  stddefs(f);
  word_sizes(f);
  byte_order(f);
  bitfield_order(f);
  fprintf(f, "\n#endif /* %s */\n", guard);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1214 <main+0x44>
mov    0x2de9(%rip),%rax
movslq (%rax),%rdi
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    140c <main+0x23c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
add    $0x5,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x5f,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x5f,(%rax)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    12dd <main+0x10d>
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x3d(%rbp)
movsbl -0x3d(%rbp),%edi
call   10b0 <isalpha@plt>
cmp    $0x0,%rax
je     12b8 <main+0xe8>
movsbl -0x3d(%rbp),%edi
call   1080 <tolower@plt>
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
jmp    12ca <main+0xfa>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x5f,(%rax)
jmp    12cf <main+0xff>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    126a <main+0x9a>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x5f,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x5f,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
lea    0xcfc(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1349 <main+0x179>
lea    0xce4(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    140c <main+0x23c>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xcc2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x34(%rbp),%rdi
call   1040 <ctime@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rdx
lea    0xca0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xcb6(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xca6(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xc9c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <stddefs@plt>
mov    -0x18(%rbp),%rdi
call   10f0 <word_sizes@plt>
mov    -0x18(%rbp),%rdi
call   1030 <byte_order@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <bitfield_order@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xc6f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    124a <main+0x6a>
mov    0x8(%rsi),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %eax,%r15d
lea    0x5(%r15),%edi
call   1090 <malloc@plt>
mov    %rax,%r14
movw   $0x5f5f,(%rax)
lea    0x2(%rax),%r13
test   %r15d,%r15d
jle    1278 <main+0x98>
mov    %r15d,%r15d
xor    %ebx,%ebx
jmp    1235 <main+0x55>
mov    %ebp,%edi
call   1080 <tolower@plt>
mov    %al,0x0(%r13,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r15
je     1275 <main+0x95>
movsbl (%r12,%rbx,1),%ebp
mov    %ebp,%edi
call   10b0 <isalpha@plt>
test   %rax,%rax
jne    1220 <main+0x40>
mov    $0x5f,%al
jmp    1227 <main+0x47>
mov    0x2d8f(%rip),%rax
movslq (%rax),%rcx
lea    0xda5(%rip),%rdi
mov    $0x19,%esi
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    $0x1,%r15d
jmp    1359 <main+0x179>
add    %rbx,%r13
movw   $0x5f5f,0x0(%r13)
movb   $0x0,0x2(%r13)
lea    0xd8f(%rip),%rsi
mov    %r12,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     136b <main+0x18b>
mov    %rax,%rbx
xor    %r15d,%r15d
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0x4(%rsp)
lea    0xd6e(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
lea    0x4(%rsp),%rdi
call   1040 <ctime@plt>
lea    0xd4f(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xd63(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
lea    0xd50(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xd48(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   10a0 <stddefs@plt>
mov    %rbx,%rdi
call   1100 <word_sizes@plt>
mov    %rbx,%rdi
call   1030 <byte_order@plt>
mov    %rbx,%rdi
call   10f0 <bitfield_order@plt>
lea    0xd21(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcaa(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%r15d
jmp    1359 <main+0x179>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"usage: machdep <outfile>\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [6 x i8] c"fopen\00"
@.str.3 = [4 x i8] c"/*\0A\00"
@.str.4 = [40 x i8] c" *\09machdep.h generated by machdep at %s\00"
@.str.5 = [6 x i8] c" */\0A\0A\00"
@.str.6 = [12 x i8] c"#ifndef %s\0A\00"
@.str.7 = [13 x i8] c"#define %s\0A\0A\00"
@.str.8 = [18 x i8] c"\0A#endif /* %s */\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 2
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %98
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %7
%25 = load i8*, i8** %7
%26 = call i32 @strlen(i8* %25)
store i32 %26, i32* %12
%27 = load i32, i32* %12
%28 = add nsw i32 %27, 5
%29 = call i8* @malloc(i32 %28)
store i8* %29, i8** %8
store i8* %29, i8** %9
%30 = load i8*, i8** %9
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %9
store i8 95, i8* %30
%32 = load i8*, i8** %9
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %9
store i8 95, i8* %32
store i32 0, i32* %11
br label %34
34: ; preds = %57, %21
%35 = load i32, i32* %11
%36 = load i32, i32* %12
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %60
38: ; preds = %34
%39 = load i8*, i8** %7
%40 = load i32, i32* %11
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
store i8 %43, i8* %13
%44 = load i8, i8* %13
%45 = call i64 @isalpha(i8 signext %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %38
%48 = load i8, i8* %13
%49 = call i32 @tolower(i8 signext %48)
%50 = trunc i32 %49 to i8
%51 = load i8*, i8** %9
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %9
store i8 %50, i8* %51
br label %56
53: ; preds = %38
%54 = load i8*, i8** %9
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %9
store i8 95, i8* %54
br label %56
56: ; preds = %53, %47
br label %57
57: ; preds = %56
%58 = load i32, i32* %11
%59 = add nsw i32 %58, 1
store i32 %59, i32* %11
br label %34
60: ; preds = %34
%61 = load i8*, i8** %9
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %9
store i8 95, i8* %61
%63 = load i8*, i8** %9
%64 = getelementptr inbounds i8, i8* %63, i32 1
store i8* %64, i8** %9
store i8 95, i8* %63
%65 = load i8*, i8** %9
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %9
store i8 0, i8* %65
%67 = load i8*, i8** %7
%68 = call i32* @fopen(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %68, i32** %6
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %72
70: ; preds = %60
%71 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %98
72: ; preds = %60
%73 = call i32 @time(i32* null)
store i32 %73, i32* %10
%74 = load i32*, i32** %6
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %74, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%76 = load i32*, i32** %6
%77 = call i8* @ctime(i32* %10)
%78 = call i32 (i32*, i8*, ...) @fprintf(i32* %76, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %77)
%79 = load i32*, i32** %6
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %79, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%81 = load i32*, i32** %6
%82 = load i8*, i8** %8
%83 = call i32 (i32*, i8*, ...) @fprintf(i32* %81, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %82)
%84 = load i32*, i32** %6
%85 = load i8*, i8** %8
%86 = call i32 (i32*, i8*, ...) @fprintf(i32* %84, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %85)
%87 = load i32*, i32** %6
%88 = call i32 @stddefs(i32* %87)
%89 = load i32*, i32** %6
%90 = call i32 @word_sizes(i32* %89)
%91 = load i32*, i32** %6
%92 = call i32 @byte_order(i32* %91)
%93 = load i32*, i32** %6
%94 = call i32 @bitfield_order(i32* %93)
%95 = load i32*, i32** %6
%96 = load i8*, i8** %8
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %95, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %96)
store i32 0, i32* %3
br label %98
98: ; preds = %72, %70, %16
%99 = load i32, i32* %3
ret i32 %99
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"usage: machdep <outfile>\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [6 x i8] c"fopen\00"
@.str.3 = [4 x i8] c"/*\0A\00"
@.str.4 = [40 x i8] c" *\09machdep.h generated by machdep at %s\00"
@.str.5 = [6 x i8] c" */\0A\0A\00"
@.str.6 = [12 x i8] c"#ifndef %s\0A\00"
@.str.7 = [13 x i8] c"#define %s\0A\0A\00"
@.str.8 = [18 x i8] c"\0A#endif /* %s */\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i64 25, i64 1, i32* %9)
br label %58
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @strlen(i8* %13)
%15 = add nsw i32 %14, 5
%16 = tail call i8* @malloc(i32 %15)
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8 95, i8* %16
%18 = getelementptr inbounds i8, i8* %16, i64 2
store i8 95, i8* %17
%19 = icmp sgt i32 %14, 0
br i1 %19, label %20, label %37
20: ; preds = %11
%21 = zext i32 %14 to i64
br label %22
22: ; preds = %20, %32
%23 = phi i64 [ 0, %20 ], [ %35, %32 ]
%24 = phi i8* [ %18, %20 ], [ %34, %32 ]
%25 = getelementptr inbounds i8, i8* %13, i64 %23
%26 = load i8, i8* %25
%27 = tail call i64 @isalpha(i8 signext %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %22
%30 = tail call i32 @tolower(i8 signext %26)
%31 = trunc i32 %30 to i8
br label %32
32: ; preds = %22, %29
%33 = phi i8 [ %31, %29 ], [ 95, %22 ]
%34 = getelementptr inbounds i8, i8* %24, i64 1
store i8 %33, i8* %24
%35 = add nuw nsw i64 %23, 1
%36 = icmp eq i64 %35, %21
br i1 %36, label %37, label %22
37: ; preds = %32, %11
%38 = phi i8* [ %18, %11 ], [ %34, %32 ]
%39 = getelementptr inbounds i8, i8* %38, i64 1
store i8 95, i8* %38
%40 = getelementptr inbounds i8, i8* %38, i64 2
store i8 95, i8* %39
store i8 0, i8* %40
%41 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %58
45: ; preds = %37
%46 = tail call i32 @time(i32* null)
store i32 %46, i32* %3
%47 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 3, i64 1, i32* %41)
%48 = call i8* @ctime(i32* %3)
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %48)
%50 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i64 5, i64 1, i32* %41)
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %16)
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %16)
%53 = call i32 @stddefs(i32* %41)
%54 = call i32 @word_sizes(i32* %41)
%55 = call i32 @byte_order(i32* %41)
%56 = call i32 @bitfield_order(i32* %41)
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %16)
br label %58
58: ; preds = %45, %43, %6
%59 = phi i32 [ 1, %6 ], [ 1, %43 ], [ 0, %45 ]
ret i32 %59
}