#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*/ buf;

/* Variables and functions */
unsigned int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int main(int argc, char **argv) {
  char *curstr;
  char *nextstr;
  unsigned int firstval;
  unsigned int secondval;
  unsigned int val;
  unsigned char buf[5];
  int count;
  if (argc != 2) {
    fprintf(stderr, "wrong number of args\n");
    exit(-1);
  }
  curstr = argv[1];
  nextstr = strchr(curstr, '.');
  if (nextstr == NULL) {
    fprintf(stderr, "only one component\n");
    exit(-1);
  }
  *nextstr = '\0';
  firstval = atoi(curstr);
  curstr = nextstr + 1;
  nextstr = strchr(curstr, '.');
  if (nextstr) {
    *nextstr = '\0';
  }
  secondval = atoi(curstr);
  if (firstval > 2) {
    fprintf(stderr, "first component out of range\n");
    exit(-1);
  }
  if (secondval > 39) {
    fprintf(stderr, "second component out of range\n");
    exit(-1);
  }
  printf("0x%x, ", (firstval * 40) + secondval);
  while (nextstr) {
    curstr = nextstr + 1;
    nextstr = strchr(curstr, '.');
    if (nextstr) {
      *nextstr = '\0';
    }
    memset(buf, 0, sizeof(buf));
    val = atoi(curstr);
    count = 0;
    while (val) {
      buf[count] = (val & 0x7f);
      val = val >> 7;
      count++;
    }
    while (count--) {
      if (count) {
        printf("0x%x, ", buf[count] | 0x80);
      } else {
        printf("0x%x, ", buf[count]);
      }
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119f <main+0x3f>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e7 <main+0x87>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     122a <main+0xca>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x2,-0x24(%rbp)
jbe    125f <main+0xff>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    0xdda(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
cmpl   $0x27,-0x28(%rbp)
jbe    1288 <main+0x128>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
imul   $0x28,-0x24(%rbp),%esi
add    -0x28(%rbp),%esi
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1392 <main+0x232>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12d8 <main+0x178>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x31(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <memset@plt>
mov    -0x18(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     132c <main+0x1cc>
mov    -0x2c(%rbp),%eax
and    $0x7f,%eax
mov    %al,%cl
movslq -0x38(%rbp),%rax
mov    %cl,-0x31(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
shr    $0x7,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12fb <main+0x19b>
jmp    1331 <main+0x1d1>
mov    -0x38(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x38(%rbp)
cmp    $0x0,%eax
je     138d <main+0x22d>
cmpl   $0x0,-0x38(%rbp)
je     1371 <main+0x211>
movslq -0x38(%rbp),%rax
movzbl -0x31(%rbp,%rax,1),%esi
or     $0x80,%esi
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1388 <main+0x228>
movslq -0x38(%rbp),%rax
movzbl -0x31(%rbp,%rax,1),%esi
lea    0xce6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1331 <main+0x1d1>
jmp    129d <main+0x13d>
lea    0xccc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    12d8 <main+0x168>
mov    0x8(%rsi),%r14
mov    %r14,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     12ea <main+0x17a>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %r14,%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,%r15
test   %rax,%rax
je     11c9 <main+0x59>
movb   $0x0,(%r15)
mov    %rbx,%rdi
call   1080 <atoi@plt>
cmp    $0x3,%r14d
jae    12fc <main+0x18c>
cmp    $0x28,%eax
jae    130e <main+0x19e>
lea    (%r14,%r14,4),%ecx
lea    (%rax,%rcx,8),%esi
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15,%r15
je     12c0 <main+0x150>
lea    0x3(%rsp),%r14
lea    0xe59(%rip),%r12
jmp    1228 <main+0xb8>
movzbl 0x3(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15,%r15
je     12c0 <main+0x150>
mov    %r15,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,%r15
test   %rax,%rax
je     1248 <main+0xd8>
movb   $0x0,(%r15)
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
call   1080 <atoi@plt>
test   %eax,%eax
je     121f <main+0xaf>
mov    $0xffffffffffffffff,%rbx
mov    %eax,%ecx
nopl   0x0(%rax)
mov    %eax,%edx
and    $0x7f,%dl
mov    %dl,0x4(%rsp,%rbx,1)
shr    $0x7,%ecx
add    $0x1,%rbx
cmp    $0x80,%eax
mov    %ecx,%eax
jae    1270 <main+0x100>
cmp    $0xffffffff,%ebx
je     121f <main+0xaf>
test   %rbx,%rbx
je     1210 <main+0xa0>
nopw   0x0(%rax,%rax,1)
movzbl 0x3(%rsp,%rbx,1),%esi
or     $0x80,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffffffffffff,%rbx
jne    12a0 <main+0x130>
jmp    1210 <main+0xa0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
lea    0xd18(%rip),%rsi
jmp    131e <main+0x1ae>
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
lea    0xd1c(%rip),%rsi
jmp    131e <main+0x1ae>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
lea    0xd1e(%rip),%rsi
jmp    131e <main+0x1ae>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
lea    0xd2a(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"wrong number of args\0A\00"
@.str.1 = [20 x i8] c"only one component\0A\00"
@.str.2 = [30 x i8] c"first component out of range\0A\00"
@.str.3 = [31 x i8] c"second component out of range\0A\00"
@.str.4 = [7 x i8] c"0x%x, \00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [5 x i8]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = call i8* @strchr(i8* %23, i8 signext 46)
store i8* %24, i8** %7
%25 = load i8*, i8** %7
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %31
27: ; preds = %19
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @exit(i32 -1)
unreachable
31: ; preds = %19
%32 = load i8*, i8** %7
store i8 0, i8* %32
%33 = load i8*, i8** %6
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %8
%35 = load i8*, i8** %7
%36 = getelementptr inbounds i8, i8* %35, i64 1
store i8* %36, i8** %6
%37 = load i8*, i8** %6
%38 = call i8* @strchr(i8* %37, i8 signext 46)
store i8* %38, i8** %7
%39 = load i8*, i8** %7
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %43
41: ; preds = %31
%42 = load i8*, i8** %7
store i8 0, i8* %42
br label %43
43: ; preds = %41, %31
%44 = load i8*, i8** %6
%45 = call i32 @atoi(i8* %44)
store i32 %45, i32* %9
%46 = load i32, i32* %8
%47 = icmp ugt i32 %46, 2
br i1 %47, label %48, label %52
48: ; preds = %43
%49 = load i32, i32* @stderr
%50 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 @exit(i32 -1)
unreachable
52: ; preds = %43
%53 = load i32, i32* %9
%54 = icmp ugt i32 %53, 39
br i1 %54, label %55, label %59
55: ; preds = %52
%56 = load i32, i32* @stderr
%57 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%58 = call i32 @exit(i32 -1)
unreachable
59: ; preds = %52
%60 = load i32, i32* %8
%61 = mul i32 %60, 40
%62 = load i32, i32* %9
%63 = add i32 %61, %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %120, %59
%66 = load i8*, i8** %7
%67 = icmp ne i8* %66, null
br i1 %67, label %68, label %121
68: ; preds = %65
%69 = load i8*, i8** %7
%70 = getelementptr inbounds i8, i8* %69, i64 1
store i8* %70, i8** %6
%71 = load i8*, i8** %6
%72 = call i8* @strchr(i8* %71, i8 signext 46)
store i8* %72, i8** %7
%73 = load i8*, i8** %7
%74 = icmp ne i8* %73, null
br i1 %74, label %75, label %77
75: ; preds = %68
%76 = load i8*, i8** %7
store i8 0, i8* %76
br label %77
77: ; preds = %75, %68
%78 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 0
%79 = call i32 @memset(i8* %78, i32 0, i32 5)
%80 = load i8*, i8** %6
%81 = call i32 @atoi(i8* %80)
store i32 %81, i32* %10
store i32 0, i32* %12
br label %82
82: ; preds = %85, %77
%83 = load i32, i32* %10
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %96
85: ; preds = %82
%86 = load i32, i32* %10
%87 = and i32 %86, 127
%88 = trunc i32 %87 to i8
%89 = load i32, i32* %12
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 %90
store i8 %88, i8* %91
%92 = load i32, i32* %10
%93 = lshr i32 %92, 7
store i32 %93, i32* %10
%94 = load i32, i32* %12
%95 = add nsw i32 %94, 1
store i32 %95, i32* %12
br label %82
96: ; preds = %82
br label %97
97: ; preds = %119, %96
%98 = load i32, i32* %12
%99 = add nsw i32 %98, -1
store i32 %99, i32* %12
%100 = icmp ne i32 %98, 0
br i1 %100, label %101, label %120
101: ; preds = %97
%102 = load i32, i32* %12
%103 = icmp ne i32 %102, 0
br i1 %103, label %104, label %112
104: ; preds = %101
%105 = load i32, i32* %12
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 %106
%108 = load i8, i8* %107
%109 = zext i8 %108 to i32
%110 = or i32 %109, 128
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %110)
br label %119
112: ; preds = %101
%113 = load i32, i32* %12
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 %114
%116 = load i8, i8* %115
%117 = zext i8 %116 to i32
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %117)
br label %119
119: ; preds = %112, %104
br label %97
120: ; preds = %97
br label %65
121: ; preds = %65
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"wrong number of args\0A\00"
@.str.1 = [20 x i8] c"only one component\0A\00"
@.str.2 = [30 x i8] c"first component out of range\0A\00"
@.str.3 = [31 x i8] c"second component out of range\0A\00"
@.str.4 = [7 x i8] c"0x%x, \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i8* @strchr(i8* dereferenceable(1) %12, i8 signext 46)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @exit(i32 -1)
unreachable
19: ; preds = %10
store i8 0, i8* %13
%20 = tail call i32 @atoi(i8* %12)
%21 = getelementptr inbounds i8, i8* %13, i64 1
%22 = tail call i8* @strchr(i8* %21, i8 signext 46)
%23 = icmp eq i8* %22, null
br i1 %23, label %25, label %24
24: ; preds = %19
store i8 0, i8* %22
br label %25
25: ; preds = %24, %19
%26 = tail call i32 @atoi(i8* %21)
%27 = icmp ugt i32 %20, 2
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%31 = tail call i32 @exit(i32 -1)
unreachable
32: ; preds = %25
%33 = icmp ugt i32 %26, 39
br i1 %33, label %34, label %38
34: ; preds = %32
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%37 = tail call i32 @exit(i32 -1)
unreachable
38: ; preds = %32
%39 = mul nuw nsw i32 %20, 40
%40 = add nuw nsw i32 %26, %39
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %40)
br i1 %23, label %82, label %43
42: ; preds = %49, %69, %53
br i1 %47, label %82, label %43
43: ; preds = %38, %42
%44 = phi i8* [ %46, %42 ], [ %22, %38 ]
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = call i8* @strchr(i8* %45, i8 signext 46)
%47 = icmp eq i8* %46, null
br i1 %47, label %49, label %48
48: ; preds = %43
store i8 0, i8* %46
br label %49
49: ; preds = %48, %43
%50 = call i32 @memset(i8* %4, i32 0, i32 5)
%51 = call i32 @atoi(i8* %45)
%52 = icmp eq i32 %51, 0
br i1 %52, label %42, label %60
53: ; preds = %60
%54 = trunc i64 %67 to i32
%55 = icmp eq i32 %54, 0
br i1 %55, label %42, label %56
56: ; preds = %53
%57 = and i64 %67, 4294967295
%58 = add nsw i64 %57, -1
%59 = icmp eq i64 %58, 0
br i1 %59, label %69, label %73
60: ; preds = %49, %60
%61 = phi i64 [ %67, %60 ], [ 0, %49 ]
%62 = phi i32 [ %66, %60 ], [ %51, %49 ]
%63 = trunc i32 %62 to i8
%64 = and i8 %63, 127
%65 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %61
store i8 %64, i8* %65
%66 = lshr i32 %62, 7
%67 = add nuw nsw i64 %61, 1
%68 = icmp ult i32 %62, 128
br i1 %68, label %53, label %60
69: ; preds = %73, %56
%70 = load i8, i8* %4
%71 = zext i8 %70 to i32
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %71)
br label %42
73: ; preds = %56, %73
%74 = phi i64 [ %80, %73 ], [ %58, %56 ]
%75 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %74
%76 = load i8, i8* %75
%77 = or i8 %76, -128
%78 = zext i8 %77 to i32
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %78)
%80 = add nsw i64 %74, -1
%81 = icmp eq i64 %80, 0
br i1 %81, label %69, label %73
82: ; preds = %42, %38
%83 = call i32 @putchar(i32 10)
ret i32 0
}