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

/* Variables and functions */
char atoi(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strtok(char *, char *);
char *getip(char *token) {
  static char ip[4];
  char *temp = malloc(strlen(token));
  strcpy(temp, token);
  ip[0] = atoi(strtok(temp, "."));
  ip[1] = atoi(strtok(NULL, "."));
  ip[2] = atoi(strtok(NULL, "."));
  ip[3] = atoi(strtok(NULL, "."));
  free(temp);
  return ip;
}


x86 assembly (clang, -O0):
<getip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %al,0x2ea7(%rip)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe4b(%rip),%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %al,0x2e8b(%rip)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe2e(%rip),%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %al,0x2e6f(%rip)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe11(%rip),%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %al,0x2e53(%rip)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0x2e40(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getip>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xe74(%rip),%r15
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %al,0x2ead(%rip)
lea    0x2ea6(%rip),%r14
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %al,0x2e90(%rip)
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %al,0x2e7a(%rip)
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
mov    %eax,%edi
call   1080 <atoi@plt>
mov    %al,0x2e64(%rip)
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@getip.ip = internal global [4 x i8] zeroinitializer
@.str = [2 x i8] c".\00"
define i8* @getip(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = call i8* @malloc(i32 %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = load i8*, i8** %2
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = load i8*, i8** %3
%11 = call i32 @strtok(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = call signext i8 @atoi(i32 %11)
store i8 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @getip.ip, i64 0, i64 0)
%13 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call signext i8 @atoi(i32 %13)
store i8 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @getip.ip, i64 0, i64 1)
%15 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = call signext i8 @atoi(i32 %15)
store i8 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @getip.ip, i64 0, i64 2)
%17 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = call signext i8 @atoi(i32 %17)
store i8 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @getip.ip, i64 0, i64 3)
%19 = load i8*, i8** %3
%20 = call i32 @free(i8* %19)
ret i8* getelementptr inbounds ([4 x i8], [4 x i8]* @getip.ip, i64 0, i64 0)
}

LLVM IR (-O2):
@getip.ip = internal global [4 x i8] zeroinitializer
@.str = [2 x i8] c".\00"
define i8* @getip(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i8* @malloc(i32 %2)
%4 = tail call i32 @strcpy(i8* %3, i8* %0)
%5 = tail call i32 @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call signext i8 @atoi(i32 %5)
store i8 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @getip.ip, i64 0, i64 0)
%7 = tail call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call signext i8 @atoi(i32 %7)
store i8 %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @getip.ip, i64 0, i64 1)
%9 = tail call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call signext i8 @atoi(i32 %9)
store i8 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @getip.ip, i64 0, i64 2)
%11 = tail call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = tail call signext i8 @atoi(i32 %11)
store i8 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @getip.ip, i64 0, i64 3)
%13 = tail call i32 @free(i8* %3)
ret i8* getelementptr inbounds ([4 x i8], [4 x i8]* @getip.ip, i64 0, i64 0)
}