#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 < 0) || (firstval > 2)) {
    fprintf(stderr, "first component out of range\n");
    exit(-1);
  }
  if ((secondval < 0) || (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   $0x0,-0x24(%rbp)
jb     124a <main+0xea>
cmpl   $0x2,-0x24(%rbp)
jbe    1269 <main+0x109>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x28(%rbp)
jb     127d <main+0x11d>
cmpl   $0x27,-0x28(%rbp)
jbe    129c <main+0x13c>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
lea    0xdbb(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
imul   $0x28,-0x24(%rbp),%esi
add    -0x28(%rbp),%esi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     13a6 <main+0x246>
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     12ec <main+0x18c>
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     1340 <main+0x1e0>
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    130f <main+0x1af>
jmp    1345 <main+0x1e5>
mov    -0x38(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x38(%rbp)
cmp    $0x0,%eax
je     13a1 <main+0x241>
cmpl   $0x0,-0x38(%rbp)
je     1385 <main+0x225>
movslq -0x38(%rbp),%rax
movzbl -0x31(%rbp,%rax,1),%esi
or     $0x80,%esi
lea    0xcee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    139c <main+0x23c>
movslq -0x38(%rbp),%rax
movzbl -0x31(%rbp,%rax,1),%esi
lea    0xcd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1345 <main+0x1e5>
jmp    12b1 <main+0x151>
lea    0xcb8(%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 ult i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %43
%49 = load i32, i32* %8
%50 = icmp ugt i32 %49, 2
br i1 %50, label %51, label %55
51: ; preds = %48, %43
%52 = load i32, i32* @stderr
%53 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 @exit(i32 -1)
unreachable
55: ; preds = %48
%56 = load i32, i32* %9
%57 = icmp ult i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %55
%59 = load i32, i32* %9
%60 = icmp ugt i32 %59, 39
br i1 %60, label %61, label %65
61: ; preds = %58, %55
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%64 = call i32 @exit(i32 -1)
unreachable
65: ; preds = %58
%66 = load i32, i32* %8
%67 = mul i32 %66, 40
%68 = load i32, i32* %9
%69 = add i32 %67, %68
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %126, %65
%72 = load i8*, i8** %7
%73 = icmp ne i8* %72, null
br i1 %73, label %74, label %127
74: ; preds = %71
%75 = load i8*, i8** %7
%76 = getelementptr inbounds i8, i8* %75, i64 1
store i8* %76, i8** %6
%77 = load i8*, i8** %6
%78 = call i8* @strchr(i8* %77, i8 signext 46)
store i8* %78, i8** %7
%79 = load i8*, i8** %7
%80 = icmp ne i8* %79, null
br i1 %80, label %81, label %83
81: ; preds = %74
%82 = load i8*, i8** %7
store i8 0, i8* %82
br label %83
83: ; preds = %81, %74
%84 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 0
%85 = call i32 @memset(i8* %84, i32 0, i32 5)
%86 = load i8*, i8** %6
%87 = call i32 @atoi(i8* %86)
store i32 %87, i32* %10
store i32 0, i32* %12
br label %88
88: ; preds = %91, %83
%89 = load i32, i32* %10
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %102
91: ; preds = %88
%92 = load i32, i32* %10
%93 = and i32 %92, 127
%94 = trunc i32 %93 to i8
%95 = load i32, i32* %12
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 %96
store i8 %94, i8* %97
%98 = load i32, i32* %10
%99 = lshr i32 %98, 7
store i32 %99, i32* %10
%100 = load i32, i32* %12
%101 = add nsw i32 %100, 1
store i32 %101, i32* %12
br label %88
102: ; preds = %88
br label %103
103: ; preds = %125, %102
%104 = load i32, i32* %12
%105 = add nsw i32 %104, -1
store i32 %105, i32* %12
%106 = icmp ne i32 %104, 0
br i1 %106, label %107, label %126
107: ; preds = %103
%108 = load i32, i32* %12
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %118
110: ; preds = %107
%111 = load i32, i32* %12
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 %112
%114 = load i8, i8* %113
%115 = zext i8 %114 to i32
%116 = or i32 %115, 128
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %116)
br label %125
118: ; preds = %107
%119 = load i32, i32* %12
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 %120
%122 = load i8, i8* %121
%123 = zext i8 %122 to i32
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %123)
br label %125
125: ; preds = %118, %110
br label %103
126: ; preds = %103
br label %71
127: ; preds = %71
%128 = 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
}